add admin command to delete individual media files

This commit is contained in:
Benjamin Lee 2024-09-14 20:20:02 -07:00
parent 7672cc8473
commit d7087c66bb
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
4 changed files with 78 additions and 3 deletions

View file

@ -23,8 +23,8 @@ use ruma::{
TimelineEventType,
},
signatures::verify_json,
EventId, MilliSecondsSinceUnixEpoch, OwnedRoomId, RoomId, RoomVersionId,
ServerName, UserId,
EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId, RoomId,
RoomVersionId, ServerName, UserId,
};
use serde_json::value::to_raw_value;
use tokio::sync::{mpsc, Mutex, RwLock};
@ -179,6 +179,12 @@ enum AdminCommand {
room_id: Box<RoomId>,
},
/// Delete media and all associated thumbnails.
DeleteMedia {
/// mxc:// URI of the media to delete
mxc: OwnedMxcUri,
},
/// Verify json signatures
/// [commandbody]()
/// # ```
@ -791,6 +797,12 @@ impl Service {
services().rooms.metadata.disable_room(&room_id, false)?;
RoomMessageEventContent::text_plain("Room enabled.")
}
AdminCommand::DeleteMedia {
mxc,
} => {
services().media.delete(mxc).await?;
RoomMessageEventContent::text_plain("Media deleted.")
}
AdminCommand::DeactivateUser {
leave_rooms,
user_id,