fix: deny room_admin on peer chat room

This commit is contained in:
oxalica 2024-09-10 12:46:47 -04:00
parent 1e944ead31
commit ab4812e101
2 changed files with 13 additions and 0 deletions

View file

@ -8,6 +8,8 @@ use blah_types::Id;
pub trait IdExt {
fn gen() -> Self;
fn gen_peer_chat_rid() -> Self;
fn is_peer_chat(&self) -> bool;
}
impl IdExt for Id {
@ -26,4 +28,8 @@ impl IdExt for Id {
fn gen_peer_chat_rid() -> Self {
Id(Self::gen().0 | i64::MIN)
}
fn is_peer_chat(&self) -> bool {
self.0 < 0
}
}

View file

@ -902,6 +902,13 @@ async fn room_admin(
"URI and payload room id mismatch",
));
}
if rid.is_peer_chat() {
return Err(error_response!(
StatusCode::BAD_REQUEST,
"invalid_request",
"operation not permitted on peer chat rooms",
));
}
match op.signee.payload.op {
RoomAdminOp::AddMember { user, permission } => {