style(db/rooms): refactor admin room pdu validating

merge-requests/181/head
AndSDev 2 years ago
parent da2dbd2877
commit 912491cb28

@ -691,14 +691,15 @@ impl Service {
.expect("#admins:server_name is a valid room alias"), .expect("#admins:server_name is a valid room alias"),
)?; )?;
if admin_room.filter(|v| v == room_id).is_some() { if admin_room.filter(|v| v == room_id).is_some() {
if pdu.event_type() == &RoomEventType::RoomEncryption { match pdu.event_type() {
RoomEventType::RoomEncryption => {
warn!("Encryption is not allowed in the admins room"); warn!("Encryption is not allowed in the admins room");
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::Forbidden, ErrorKind::Forbidden,
"Encryption is not allowed in the admins room.", "Encryption is not allowed in the admins room.",
)); ));
} }
if pdu.event_type() == &RoomEventType::RoomMember { RoomEventType::RoomMember => {
#[derive(Deserialize)] #[derive(Deserialize)]
struct ExtractMembership { struct ExtractMembership {
membership: MembershipState, membership: MembershipState,
@ -733,6 +734,8 @@ impl Service {
} }
} }
} }
_ => {}
}
} }
// We append to state before appending the pdu, so we don't have a moment in time with the // We append to state before appending the pdu, so we don't have a moment in time with the

Loading…
Cancel
Save