From: Ian Jackson Date: Sun, 8 Nov 2020 11:58:54 +0000 (+0000) Subject: wip new game joining X-Git-Tag: otter-0.2.0~548 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=6e134827548ece3f238b538a939c28d8ca88623c;p=otter.git wip new game joining Signed-off-by: Ian Jackson --- diff --git a/src/accounts.rs b/src/accounts.rs index e931b0c8..e87cb490 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -45,7 +45,7 @@ impl AccountScope { > (&'out self, ns: NS, mut f: F) { - const ENCODE : percent_encoding::AsciiSet = + const ENCODE : &percent_encoding::AsciiSet = percent_encoding::NON_ALPHANUMERIC; match &self { diff --git a/src/bin/otter.rs b/src/bin/otter.rs index af88ef45..888a4fa8 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -386,7 +386,7 @@ fn setup_table(ma: &MainOpts, chan: &mut ConnForGame, insns.push(MGI::SetACL { acl }); isnns.push(MGI::SetTimezone { tz: timezone.clone() }); - +/* let (_, nick2id) = chan.get_info()?; @@ -448,7 +448,7 @@ fn setup_table(ma: &MainOpts, chan: &mut ConnForGame, &pspec.nick))?; } } - +*/ Ok(()) } diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 8884b43e..2431b79d 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -501,6 +501,19 @@ fn execute_game_insn<'cs, 'igr, 'ig : 'igr>( raw: None }, Fine, ig_g) }, + + SetACL { acl } => { + let ag = AccountsGuard::lock(); + let (ig, _) = cs.check_acl(&ag, ig, PCH::Instance, &[TP::ChangeACL])?; + ig.acl = acl.into(); + (U{ pcs: vec![ ], + log: vec![ LogEntry { + html: Html(format!("{} set the table access control list", + &who)), + } ], + raw: None }, + Fine, ig) + }, }; Ok(y) } diff --git a/src/spec.rs b/src/spec.rs index 9b2afc5d..3263f86fe 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -61,8 +61,8 @@ display_as_debug!{SpecError} #[derive(Debug,Serialize,Deserialize)] pub struct TableSpec { #[serde(default)] pub players: Vec, - pub player_perms: Option>, - #[serde(default)] pub acl: Acl, + pub player_perms: Option>, + #[serde(default)] pub acl: Acl, pub timezone: Option, } @@ -245,6 +245,9 @@ pub mod implementation { use super::*; use crate::imports::*; + type AS = AccountScope; + type TPS = TablePlayerSpec; + impl Default for Acl

{ fn default() -> Self { Acl { ents: default() } } } @@ -270,15 +273,17 @@ pub mod implementation { impl TablePlayerSpec { fn account_glob(&self) -> String { fn scope_glob(scope: AccountScope) -> String { - foramt!("{}:*", &scope) + let mut out = "".to_string(); + scope.display_name(&["*"], |s| Ok::<_,Impossible>(out += s)).unwrap(); + out } match self { - Account(account) => account.to_string(), - AccountGlob(s) => s.clone(), - Local(user) => scope_glob(AS::Unix { user: user.clone() }), - AllLocal => { + TPS::Account(account) => account.to_string(), + TPS::AccountGlob(s) => s.clone(), + TPS::Local(user) => scope_glob(AS::Unix { user: user.clone() }), + TPS::AllLocal => { // abuse that usernames are not encoded - scope_glob(AS::Unix { user: "*".clone() }) + scope_glob(AS::Unix { user: "*".into() }) }, } }