Fix room permission check

This commit is contained in:
oxalica 2024-08-29 18:19:26 -04:00
parent d672d067cd
commit 4456513139
2 changed files with 4 additions and 2 deletions

View file

@ -452,11 +452,13 @@ async fn room_post_item(
JOIN `room_member` USING (`rid`)
JOIN `user` USING (`uid`)
WHERE `ruuid` = :ruuid AND
`userkey` = :userkey
`userkey` = :userkey AND
(`room_member`.`permission` & :perm) = :perm
",
named_params! {
":ruuid": ruuid,
":userkey": &chat.signee.user,
":perm": RoomPermission::POST_CHAT,
},
|row| Ok((row.get::<_, u64>("rid")?, row.get::<_, u64>("uid")?)),
)

View file

@ -125,7 +125,7 @@ bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RoomPermission: u64 {
const PUSH_CHAT = 1 << 0;
const POST_CHAT = 1 << 0;
const ADD_MEMBER = 1 << 1;
const ALL = !0;