admin cmd to delete multiple MXC URLs in bulk
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
45ad7b40b3
commit
50fb202382
1 changed files with 25 additions and 0 deletions
|
@ -89,6 +89,9 @@ enum MediaCommand {
|
||||||
/// The MXC URI to delete
|
/// The MXC URI to delete
|
||||||
mxc: Box<MxcUri>,
|
mxc: Box<MxcUri>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// - Deletes a codeblock list of MXC URLs from our database and on the filesystem
|
||||||
|
DeleteList,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(test, derive(Debug))]
|
#[cfg_attr(test, derive(Debug))]
|
||||||
|
@ -629,6 +632,28 @@ impl Service {
|
||||||
"Deleted the MXC from our database and on our filesystem.",
|
"Deleted the MXC from our database and on our filesystem.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
MediaCommand::DeleteList => {
|
||||||
|
if body.len() > 2
|
||||||
|
&& body[0].trim().starts_with("```")
|
||||||
|
&& body.last().unwrap().trim() == "```"
|
||||||
|
{
|
||||||
|
let mxc_list = body.clone().drain(1..body.len() - 1).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let mut mxc_deletion_count = 0;
|
||||||
|
|
||||||
|
for mxc in mxc_list {
|
||||||
|
debug!("Deleting MXC {} in bulk", mxc);
|
||||||
|
services().media.delete(mxc.to_owned()).await?;
|
||||||
|
mxc_deletion_count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(RoomMessageEventContent::text_plain(format!("Finished bulk MXC deletion, deleted {} total MXCs from our database and the filesystem.", mxc_deletion_count)));
|
||||||
|
} else {
|
||||||
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
"Expected code block in command body. Add --help for details.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
AdminCommand::Users(command) => match command {
|
AdminCommand::Users(command) => match command {
|
||||||
UserCommand::List => match services().users.list_local_users() {
|
UserCommand::List => match services().users.list_local_users() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue