Files
continuwuity/src/admin/media/mod.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

112 lines
2.7 KiB
Rust
Raw Normal View History

#![allow(rustdoc::broken_intra_doc_links)]
mod commands;
2024-04-20 19:55:14 -04:00
use clap::Subcommand;
2024-12-14 21:58:01 -05:00
use conduwuit::Result;
use ruma::{OwnedEventId, OwnedMxcUri, OwnedServerName};
2024-04-20 19:55:14 -04:00
2024-07-27 00:11:41 +00:00
use crate::admin_command_dispatch;
2024-04-20 19:55:14 -04:00
2024-07-27 00:11:41 +00:00
#[admin_command_dispatch]
#[derive(Debug, Subcommand)]
2025-05-24 00:28:09 +01:00
pub enum MediaCommand {
/// Deletes a single media file from our database and on the filesystem
/// via a single MXC URL or event ID (not redacted)
2024-04-20 19:55:14 -04:00
Delete {
/// The MXC URL to delete
#[arg(long)]
mxc: Option<OwnedMxcUri>,
2024-04-20 19:55:14 -04:00
/// The message event ID which contains the media and thumbnail MXC
2024-04-20 19:55:14 -04:00
/// URLs
#[arg(long)]
event_id: Option<OwnedEventId>,
2024-04-20 19:55:14 -04:00
},
/// Deletes a codeblock list of MXC URLs from our database and on the
/// filesystem. This will always ignore errors.
2024-04-20 19:55:14 -04:00
DeleteList,
/// Deletes all remote (and optionally local) media created before/after
/// [duration] ago, using filesystem metadata first created at date, or
/// fallback to last modified date. This will always ignore errors by
/// default.
///
/// * Examples:
/// * Delete all remote media older than a year:
///
/// `!admin media delete-past-remote-media -b 1y`
///
/// * Delete all remote and local media from 3 days ago, up until now:
///
/// `!admin media delete-past-remote-media -a 3d
///-yes-i-want-to-delete-local-media`
#[command(verbatim_doc_comment)]
2024-04-20 19:55:14 -04:00
DeletePastRemoteMedia {
/// The relative time (e.g. 30s, 5m, 7d) from now within which to
/// search
2024-04-20 19:55:14 -04:00
duration: String,
/// Only delete media created before [duration] ago
#[arg(long, short)]
before: bool,
/// Only delete media created after [duration] ago
#[arg(long, short)]
after: bool,
/// Long argument to additionally delete local media
#[arg(long)]
yes_i_want_to_delete_local_media: bool,
2024-04-20 19:55:14 -04:00
},
/// Deletes all the local media from a local user on our server. This will
/// always ignore errors by default.
DeleteAllFromUser {
username: String,
},
/// Deletes all remote media from the specified remote server. This will
/// always ignore errors by default.
DeleteAllFromServer {
server_name: OwnedServerName,
/// Long argument to delete local media
#[arg(long)]
yes_i_want_to_delete_local_media: bool,
},
GetFileInfo {
/// The MXC URL to lookup info for.
mxc: OwnedMxcUri,
},
GetRemoteFile {
/// The MXC URL to fetch
mxc: OwnedMxcUri,
#[arg(short, long)]
server: Option<OwnedServerName>,
#[arg(short, long, default_value("10000"))]
timeout: u32,
},
GetRemoteThumbnail {
/// The MXC URL to fetch
mxc: OwnedMxcUri,
#[arg(short, long)]
server: Option<OwnedServerName>,
#[arg(short, long, default_value("10000"))]
timeout: u32,
2025-05-24 00:28:09 +01:00
#[arg(long, default_value("800"))]
width: u32,
2025-05-24 00:28:09 +01:00
#[arg(long, default_value("800"))]
height: u32,
},
2024-04-20 19:55:14 -04:00
}