chiark / gitweb /
wip new game joining
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Nov 2020 11:58:54 +0000 (11:58 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Nov 2020 11:58:54 +0000 (11:58 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/accounts.rs
src/bin/otter.rs
src/cmdlistener.rs
src/spec.rs

index e931b0c83158ee8239d403bed5b3453258c5d37c..e87cb490e95048880239fd300ec739b6fccc73b5 100644 (file)
@@ -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 {
index af88ef4593c88251762121a6232d95798701ab8d..888a4fa8adb57e7e1768591d0a6d20e2d31f41e3 100644 (file)
@@ -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(())
 }
 
index 8884b43e86c6362f90be90063d272851d33ae8fa..2431b79dd4c99e3ced3f41788c80f2171da33789 100644 (file)
@@ -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)
 }
index 9b2afc5d6cbf9b80343c1b4ecc78d9c8501067a5..3263f86fee338cabca22cb048b6e88966a29cc05 100644 (file)
@@ -61,8 +61,8 @@ display_as_debug!{SpecError}
 #[derive(Debug,Serialize,Deserialize)]
 pub struct TableSpec {
   #[serde(default)] pub players: Vec<TablePlayerSpec>,
-  pub player_perms: Option<HashSet<Perm>>,
-  #[serde(default)] pub acl: Acl<AclEntry>,
+  pub player_perms: Option<HashSet<TablePermission>>,
+  #[serde(default)] pub acl: Acl<TablePermission>,
   pub timezone: Option<String>,
 }
 
@@ -245,6 +245,9 @@ pub mod implementation {
   use super::*;
   use crate::imports::*;
 
+  type AS = AccountScope;
+  type TPS = TablePlayerSpec;
+
   impl<P: Eq + Hash> Default for Acl<P> {
     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() })
         },
       }
     }