add admin command to delete all local media by a local user
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
e790785db8
commit
2b7e0dcb80
2 changed files with 26 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
use conduit::{debug, info, Result};
|
||||
use ruma::{events::room::message::RoomMessageEventContent, EventId, MxcUri};
|
||||
|
||||
use crate::admin_command;
|
||||
use crate::{admin_command, utils::parse_local_user_id};
|
||||
|
||||
#[admin_command]
|
||||
pub(super) async fn delete(
|
||||
|
@ -186,3 +186,18 @@ pub(super) async fn delete_past_remote_media(&self, duration: String, force: boo
|
|||
"Deleted {deleted_count} total files.",
|
||||
)))
|
||||
}
|
||||
|
||||
#[admin_command]
|
||||
pub(super) async fn delete_all_from_user(&self, username: String, force: bool) -> Result<RoomMessageEventContent> {
|
||||
let user_id = parse_local_user_id(self.services, &username)?;
|
||||
|
||||
let deleted_count = self
|
||||
.services
|
||||
.media
|
||||
.delete_from_user(&user_id, force)
|
||||
.await?;
|
||||
|
||||
Ok(RoomMessageEventContent::text_plain(format!(
|
||||
"Deleted {deleted_count} total files.",
|
||||
)))
|
||||
}
|
||||
|
|
|
@ -32,8 +32,18 @@ pub(super) enum MediaCommand {
|
|||
/// - The duration (at or after), e.g. "5m" to delete all media in the
|
||||
/// past 5 minutes
|
||||
duration: String,
|
||||
|
||||
/// Continues deleting remote media if an undeletable object is found
|
||||
#[arg(short, long)]
|
||||
force: bool,
|
||||
},
|
||||
|
||||
/// - Deletes all the local media from a local user on our server
|
||||
DeleteAllFromUser {
|
||||
username: String,
|
||||
|
||||
/// Continues deleting media if an undeletable object is found
|
||||
#[arg(short, long)]
|
||||
force: bool,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue