mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 00:31:09 +00:00
fix: deny room_admin on peer chat room
This commit is contained in:
parent
1e944ead31
commit
ab4812e101
2 changed files with 13 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 } => {
|
||||
|
|
Loading…
Add table
Reference in a new issue