gatewayd: approvals answered from Mattermost; typing paused; the notice
Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
pub mod text;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::{Mutex, MutexGuard};
|
||||
|
||||
@@ -44,6 +44,8 @@ pub enum Judged {
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Registry {
|
||||
posted: Mutex<HashMap<u64, Posted>>,
|
||||
/// Every approval ever posted here, answered or not: for the notice.
|
||||
ever: Mutex<HashSet<u64>>,
|
||||
}
|
||||
|
||||
impl Registry {
|
||||
@@ -56,6 +58,10 @@ impl Registry {
|
||||
}
|
||||
|
||||
pub fn add(&self, posted: Posted) {
|
||||
self.ever
|
||||
.lock()
|
||||
.unwrap_or_else(|p| p.into_inner())
|
||||
.insert(posted.approval);
|
||||
self.lock().insert(posted.approval, posted);
|
||||
}
|
||||
|
||||
@@ -73,6 +79,14 @@ impl Registry {
|
||||
self.lock().values().map(|p| p.session.clone()).collect()
|
||||
}
|
||||
|
||||
/// Was approval `id` ever posted here?
|
||||
pub fn was_posted(&self, id: u64) -> bool {
|
||||
self.ever
|
||||
.lock()
|
||||
.unwrap_or_else(|p| p.into_inner())
|
||||
.contains(&id)
|
||||
}
|
||||
|
||||
/// Judge a command from `user`, posted as `post` at `at` in the thread `root`, in the order of
|
||||
/// the spec's section 7. An accepted answer is taken out and sent; nothing else changes.
|
||||
pub fn judge(
|
||||
|
||||
Reference in New Issue
Block a user