refactor(redactions): move checks inside conduit

ruma was already accidentally performing these checks for us, but this shouldn't be the case
This commit is contained in:
Matthias Ahouansou 2024-04-23 21:42:01 +01:00
parent 2d8c551cd5
commit 00d6aeddb6
No known key found for this signature in database
3 changed files with 97 additions and 4 deletions

View file

@ -24,7 +24,7 @@ use ruma::{
},
events::{
room::{create::RoomCreateEventContent, server_acl::RoomServerAclEventContent},
StateEventType,
StateEventType, TimelineEventType,
},
int,
serde::Base64,
@ -796,7 +796,18 @@ impl Service {
None::<PduEvent>,
|k, s| auth_events.get(&(k.clone(), s.to_owned())),
)
.map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))?;
.map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))?
|| if let Some(redact_id) = &incoming_pdu.redacts {
incoming_pdu.kind == TimelineEventType::RoomRedaction
&& !services().rooms.state_accessor.user_can_redact(
redact_id,
&incoming_pdu.sender,
&incoming_pdu.room_id,
true,
)?
} else {
false
};
// 13. Use state resolution to find new room state