admin command to delete media via MXC url
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
27c29e6063
commit
4d624846ee
4 changed files with 85 additions and 41 deletions
|
@ -27,8 +27,8 @@ use ruma::{
|
|||
},
|
||||
TimelineEventType,
|
||||
},
|
||||
EventId, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomAliasId, RoomId, RoomOrAliasId,
|
||||
RoomVersionId, ServerName, UserId,
|
||||
EventId, MxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomAliasId, RoomId,
|
||||
RoomOrAliasId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
use tokio::sync::{mpsc, Mutex};
|
||||
|
@ -69,6 +69,10 @@ enum AdminCommand {
|
|||
/// - Commands for managing the server
|
||||
Server(ServerCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// - Commands for managing media
|
||||
Media(MediaCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
// TODO: should i split out debug commands to a separate thing? the
|
||||
// debug commands seem like they could fit in the other categories fine
|
||||
|
@ -77,6 +81,16 @@ enum AdminCommand {
|
|||
Debug(DebugCommand),
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Debug))]
|
||||
#[derive(Subcommand)]
|
||||
enum MediaCommand {
|
||||
/// - Deletes a single media file from our database and on the filesystem via a single MXC URI
|
||||
Delete {
|
||||
/// The MXC URI to delete
|
||||
mxc: Box<MxcUri>,
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Debug))]
|
||||
#[derive(Subcommand)]
|
||||
enum AppserviceCommand {
|
||||
|
@ -606,6 +620,16 @@ impl Service {
|
|||
}
|
||||
}
|
||||
},
|
||||
AdminCommand::Media(command) => match command {
|
||||
MediaCommand::Delete { mxc } => {
|
||||
debug!("Got MXC URI: {}", mxc);
|
||||
services().media.delete(mxc.to_string()).await?;
|
||||
|
||||
return Ok(RoomMessageEventContent::text_plain(
|
||||
"Deleted the MXC from our database and on our filesystem.",
|
||||
));
|
||||
}
|
||||
},
|
||||
AdminCommand::Users(command) => match command {
|
||||
UserCommand::List => match services().users.list_local_users() {
|
||||
Ok(users) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue