feat: implement time based message sweep on user ban (#670)
* feat: implement time based message sweep on user ban - Adds `delete_message_seconds` (0 to 7 days in seconds) to the ban request payload. Signed-off-by: arsabutispik <ispik@ispik.dev> * refactor: pass ulid conversion to database Signed-off-by: arsabutispik <ispik@ispik.dev> * fix: use COL constant instead of hardcoded string in error mapper Signed-off-by: arsabutispik <ispik@ispik.dev> * refactor: broadcast bulk delete events during ban sweep Updates the `delete_messages_by_author_since` trait to return a HashMap of deleted message IDs grouped by channel. The MongoDB implementation now uses a two-step process: it first runs a projected `find` query to gather the target `_id` and `channel` fields, then executes the `delete_many` operation. This allows the ban route to loop through the affected channels and dispatch `EventV1::BulkMessageDelete` WebSocket events, ensuring that the swept messages are instantly removed from the UI for all connected clients. Signed-off-by: arsabutispik <ispik@ispik.dev> * refactor: optimize message deletion by using $group and aggregate Signed-off-by: arsabutispik <ispik@ispik.dev> * refactor: use with_type in query Signed-off-by: arsabutispik <ispik@ispik.dev> * refactor: abstract function to Message model and mark attachments as deleted Signed-off-by: arsabutispik <ispik@ispik.dev> --------- Signed-off-by: arsabutispik <ispik@ispik.dev>
This commit is contained in:
@@ -19,6 +19,9 @@ auto_derived!(
|
||||
/// Ban reason
|
||||
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 1024)))]
|
||||
pub reason: Option<String>,
|
||||
/// Messages to delete in seconds
|
||||
#[cfg_attr(feature = "validator", validate(range(min = 0, max = 604800)))]
|
||||
pub delete_message_seconds: Option<i64>,
|
||||
}
|
||||
|
||||
/// Just enough information to list a ban
|
||||
|
||||
Reference in New Issue
Block a user