access control and command handling with regex
This commit is contained in:
+13
-1
@@ -101,6 +101,14 @@ impl GroupConfig {
|
||||
self.mark_dirty();
|
||||
}
|
||||
|
||||
pub(crate) fn get_admins(&self) -> impl Iterator<Item=&String> {
|
||||
self.admin_users.iter()
|
||||
}
|
||||
|
||||
pub(crate) fn get_members(&self) -> impl Iterator<Item=&String> {
|
||||
self.member_users.iter()
|
||||
}
|
||||
|
||||
pub(crate) fn set_last_notif(&mut self, ts: u64) {
|
||||
self.last_notif_ts = self.last_notif_ts.max(ts);
|
||||
self.mark_dirty();
|
||||
@@ -127,10 +135,14 @@ impl GroupConfig {
|
||||
|| self.is_users_server_banned(acct)
|
||||
}
|
||||
|
||||
pub(crate) fn is_server_banned(&self, server: &str) -> bool {
|
||||
self.banned_servers.contains(server)
|
||||
}
|
||||
|
||||
/// Check if the user's server is banned
|
||||
fn is_users_server_banned(&self, acct: &str) -> bool {
|
||||
let server = acct_to_server(acct);
|
||||
self.banned_servers.contains(server)
|
||||
self.is_server_banned(server)
|
||||
}
|
||||
|
||||
pub(crate) fn can_write(&self, acct: &str) -> bool {
|
||||
|
||||
+2
-2
@@ -170,9 +170,9 @@ impl ConfigStore {
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum GroupError {
|
||||
#[error("Operation refused because the user is admin")]
|
||||
#[error("User is admin")]
|
||||
UserIsAdmin,
|
||||
#[error("Operation refused because the user is banned")]
|
||||
#[error("User is banned")]
|
||||
UserIsBanned,
|
||||
#[error("Server could not be banned because there are admin users on it")]
|
||||
AdminsOnServer,
|
||||
|
||||
Reference in New Issue
Block a user