mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-09 13:26:41 +02:00
fix: made it so remove acl command will say if a non-existing entry is attempted to be removed
This commit is contained in:
parent
d325537308
commit
580b6af894
4 changed files with 20 additions and 12 deletions
|
@ -39,8 +39,12 @@ impl Data for KeyValueDatabase {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_acl(&self, host: Host<String>) -> crate::Result<()> {
|
fn remove_acl(&self, host: Host<String>) -> crate::Result<Option<()>> {
|
||||||
self.acl_list.remove(host.to_string().as_bytes())
|
if self.acl_list.get(host.to_string().as_bytes())?.is_none() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
self.acl_list.remove(host.to_string().as_bytes())?;
|
||||||
|
Ok(Some(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_all_acls(&self) -> HashSet<AclDatabaseEntry> {
|
fn get_all_acls(&self) -> HashSet<AclDatabaseEntry> {
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub trait Data: Send + Sync {
|
||||||
/// add a given Acl entry to the database
|
/// add a given Acl entry to the database
|
||||||
fn add_acl(&self, acl: AclDatabaseEntry) -> crate::Result<()>;
|
fn add_acl(&self, acl: AclDatabaseEntry) -> crate::Result<()>;
|
||||||
/// remove a given Acl entry from the database
|
/// remove a given Acl entry from the database
|
||||||
fn remove_acl(&self, host: Host<String>) -> crate::Result<()>;
|
fn remove_acl(&self, host: Host<String>) -> crate::Result<Option<()>>;
|
||||||
|
|
||||||
/// list all acls
|
/// list all acls
|
||||||
fn get_all_acls(&self) -> HashSet<AclDatabaseEntry>;
|
fn get_all_acls(&self) -> HashSet<AclDatabaseEntry>;
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl Service {
|
||||||
None => set.into_iter().collect(),
|
None => set.into_iter().collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn remove_acl(&self, host: Host) -> crate::Result<()> {
|
pub fn remove_acl(&self, host: Host) -> crate::Result<Option<()>> {
|
||||||
self.db.remove_acl(host)
|
self.db.remove_acl(host)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1300,14 +1300,18 @@ impl Service {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(error) = services().acl.remove_acl(host.clone()) {
|
match services().acl.remove_acl(host.clone()) {
|
||||||
|
Err(error) => {
|
||||||
error!(
|
error!(
|
||||||
"encountered {} while trying to remove acl with host {}",
|
"encountered {} while trying to remove acl with host {}",
|
||||||
error, host
|
error, host
|
||||||
);
|
);
|
||||||
RoomMessageEventContent::text_plain("error, couldn't remove acl")
|
RoomMessageEventContent::text_plain("error, couldn't remove acl")
|
||||||
} else {
|
}
|
||||||
RoomMessageEventContent::text_plain("successfully removed ACL")
|
Ok(Some(_)) => RoomMessageEventContent::text_plain("successfully removed ACL"),
|
||||||
|
Ok(None) => RoomMessageEventContent::text_plain(
|
||||||
|
"couldn't remove acl as it doesn't exist",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AdminCommand::Acl(AclCommand::List { filter }) => {
|
AdminCommand::Acl(AclCommand::List { filter }) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue