feat: Add local media self-redaction

This commit is contained in:
timedout
2026-01-25 03:13:12 +00:00
parent 6cb9d50383
commit d90d22c917
5 changed files with 56 additions and 15 deletions
+28
View File
@@ -14,6 +14,7 @@ use reqwest::Url;
use ruma::{
Mxc, UserId,
api::client::{
authenticated_media,
authenticated_media::{
get_content, get_content_as_filename, get_content_thumbnail, get_media_config,
get_media_preview,
@@ -244,6 +245,33 @@ pub(crate) async fn get_media_preview_route(
})
}
#[tracing::instrument(
name = "media_redact",
level = "debug",
skip_all,
fields(%_client),
)]
pub(crate) async fn redact_media_route(
State(services): State<crate::State>,
InsecureClientIp(_client): InsecureClientIp,
body: Ruma<authenticated_media::redact::unstable::Request>,
) -> Result<authenticated_media::redact::unstable::Response> {
let user = body.sender_user();
let mxc = Mxc {
server_name: &body.server_name,
media_id: &body.media_id,
};
if !services.media.user_owns(&user, &mxc).await {
return Err!(Request(Forbidden("You do not have permission to redact this attachment.")));
}
services.media.delete(&mxc).await?; // TODO: Only delete file and mark as redacted
Ok(authenticated_media::redact::unstable::Response {})
}
async fn fetch_thumbnail(
services: &Services,
mxc: &Mxc<'_>,