initial implementation of banning room IDs

takes a full room ID, evicts all our users from that room,
adds room ID to banned room IDs metadata db table, and
forbids any new local users from attempting to join it.

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry authored and June committed 2024-02-20 07:06:57 -05:00
1 parent a92f291bbf
commit ed0c8e86f7
6 files changed
+189 -3

No files matched your search

+3
View File
@@ -6,4 +6,7 @@ pub trait Data: Send + Sync {
fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a>;
fn is_disabled(&self, room_id: &RoomId) -> Result<bool>;
fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()>;
fn is_banned(&self, room_id: &RoomId) -> Result<bool>;
fn ban_room(&self, room_id: &RoomId, banned: bool) -> Result<()>;
fn list_banned_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a>;
}
+12
View File
@@ -27,4 +27,16 @@ impl Service {
pub fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()> {
self.db.disable_room(room_id, disabled)
}
pub fn is_banned(&self, room_id: &RoomId) -> Result<bool> {
self.db.is_banned(room_id)
}
pub fn ban_room(&self, room_id: &RoomId, banned: bool) -> Result<()> {
self.db.ban_room(room_id, banned)
}
pub fn list_banned_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
self.db.list_banned_rooms()
}
}