forked from jmug/stoatchat
feat: restrict permissions for users in timeout
This commit is contained in:
@@ -2,7 +2,7 @@ use std::collections::HashSet;
|
||||
|
||||
use crate::{
|
||||
models::Channel, permissions::PermissionCalculator, Override, Permission, PermissionValue,
|
||||
Permissions, Perms, Result, DEFAULT_PERMISSION_DIRECT_MESSAGE,
|
||||
Permissions, Perms, Result, ALLOW_IN_TIMEOUT, DEFAULT_PERMISSION_DIRECT_MESSAGE,
|
||||
DEFAULT_PERMISSION_SAVED_MESSAGES, DEFAULT_PERMISSION_VIEW_ONLY,
|
||||
};
|
||||
|
||||
@@ -76,6 +76,11 @@ async fn calculate_server_permission(
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Revoke permissions if member is timed out.
|
||||
if member.in_timeout() {
|
||||
permissions.restrict(*ALLOW_IN_TIMEOUT);
|
||||
}
|
||||
|
||||
Ok(permissions)
|
||||
}
|
||||
|
||||
@@ -206,6 +211,11 @@ async fn calculate_channel_permission(
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Revoke permissions if member is timed out.
|
||||
if member.in_timeout() {
|
||||
permissions.restrict(*ALLOW_IN_TIMEOUT);
|
||||
}
|
||||
|
||||
permissions
|
||||
} else {
|
||||
(Permission::GrantAllSafe as u64).into()
|
||||
|
||||
Reference in New Issue
Block a user