access control and command handling with regex

This commit is contained in:
2021-08-22 01:50:07 +02:00
parent 5a631f785e
commit 99d9b83c68
7 changed files with 793 additions and 113 deletions
+13 -1
View File
@@ -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
View File
@@ -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,