mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
7e4071c117
**Does not yet work!** Currently, state resolution does not correctly resolve conflicting states. Everything else appears to work as expected, so stateres will be fixed soon, then we should be clear for takeoff. Also: a lot of things currently accept a nullable room ID that really just don't need to. This will need tidying up before merge. Some authentication checks have also been disabled temporarily but nothing important. A lot of things are tagged with `TODO(hydra)`, those need resolving before merge. External contributors should PR to the `hydra/public` branch, *not* ` main`. --- This PR should be squash merged. Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/943 Co-authored-by: nexy7574 <git@nexy7574.co.uk> Co-committed-by: nexy7574 <git@nexy7574.co.uk>
48 lines
1.3 KiB
Rust
48 lines
1.3 KiB
Rust
use axum::extract::State;
|
|
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
|
|
use ruma::{
|
|
api::client::redact::redact_event, events::room::redaction::RoomRedactionEventContent,
|
|
};
|
|
|
|
use crate::Ruma;
|
|
|
|
/// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}`
|
|
///
|
|
/// Tries to send a redaction event into the room.
|
|
///
|
|
/// - TODO: Handle txn id
|
|
pub(crate) async fn redact_event_route(
|
|
State(services): State<crate::State>,
|
|
body: Ruma<redact_event::v3::Request>,
|
|
) -> Result<redact_event::v3::Response> {
|
|
let sender_user = body.sender_user();
|
|
let body = &body.body;
|
|
if services.users.is_suspended(sender_user).await? {
|
|
// TODO: Users can redact their own messages while suspended
|
|
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
|
|
}
|
|
|
|
let state_lock = services.rooms.state.mutex.lock(&body.room_id).await;
|
|
|
|
let event_id = services
|
|
.rooms
|
|
.timeline
|
|
.build_and_append_pdu(
|
|
PduBuilder {
|
|
redacts: Some(body.event_id.clone()),
|
|
..PduBuilder::timeline(&RoomRedactionEventContent {
|
|
redacts: Some(body.event_id.clone()),
|
|
reason: body.reason.clone(),
|
|
})
|
|
},
|
|
sender_user,
|
|
Some(&body.room_id),
|
|
&state_lock,
|
|
)
|
|
.await?;
|
|
|
|
drop(state_lock);
|
|
|
|
Ok(redact_event::v3::Response { event_id })
|
|
}
|