forked from jmug/stoatchat
fix: revoke all channel permissions if can't view
This commit is contained in:
@@ -118,6 +118,10 @@ pub async fn calculate_channel_permissions<P: PermissionQuery>(query: &mut P) ->
|
||||
permissions.restrict(*ALLOW_IN_TIMEOUT);
|
||||
}
|
||||
|
||||
if !permissions.has_channel_permission(ChannelPermission::ViewChannel) {
|
||||
permissions.revoke_all();
|
||||
}
|
||||
|
||||
permissions
|
||||
} else {
|
||||
0_u64.into()
|
||||
|
||||
@@ -28,6 +28,11 @@ impl PermissionValue {
|
||||
self.0 &= !v;
|
||||
}
|
||||
|
||||
/// Revoke all permissions
|
||||
pub fn revoke_all(&mut self) {
|
||||
self.0 = 0;
|
||||
}
|
||||
|
||||
/// Restrict to given permissions
|
||||
pub fn restrict(&mut self, v: u64) {
|
||||
self.0 &= v;
|
||||
|
||||
Reference in New Issue
Block a user