Merge remote-tracking branch 'origin/main' into chore/utoipa
This commit is contained in:
@@ -61,6 +61,15 @@ pub async fn calculate_server_permissions<P: PermissionQuery>(query: &mut P) ->
|
||||
permissions.apply(role_override);
|
||||
}
|
||||
|
||||
if !query.do_we_have_publish_overwrites().await {
|
||||
permissions.revoke(ChannelPermission::Speak as u64);
|
||||
permissions.revoke(ChannelPermission::Video as u64);
|
||||
}
|
||||
|
||||
if !query.do_we_have_receive_overwrites().await {
|
||||
permissions.revoke(ChannelPermission::Listen as u64);
|
||||
}
|
||||
|
||||
if query.are_we_timed_out().await {
|
||||
permissions.restrict(*ALLOW_IN_TIMEOUT);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ pub enum ChannelPermission {
|
||||
DeafenMembers = 1 << 34,
|
||||
/// Move members between voice channels
|
||||
MoveMembers = 1 << 35,
|
||||
/// Listen to other users
|
||||
Listen = 1 << 36,
|
||||
|
||||
// * Channel permissions two electric boogaloo
|
||||
/// Mention everyone and online members
|
||||
@@ -130,7 +132,9 @@ pub static DEFAULT_PERMISSION: Lazy<u64> = Lazy::new(|| {
|
||||
+ ChannelPermission::SendEmbeds
|
||||
+ ChannelPermission::UploadFiles
|
||||
+ ChannelPermission::Connect
|
||||
+ ChannelPermission::Speak,
|
||||
+ ChannelPermission::Speak
|
||||
+ ChannelPermission::Listen
|
||||
+ ChannelPermission::Video
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ pub enum DataPermissionPoly {
|
||||
permissions: u64,
|
||||
},
|
||||
Field {
|
||||
/// Allow / deny values to set for members in this `TextChannel` or `VoiceChannel`
|
||||
/// Allow / deny values to set for members in this server channel
|
||||
permissions: Override,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -64,6 +64,14 @@ async fn validate_user_permissions() {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
async fn do_we_have_publish_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn do_we_have_receive_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn get_channel_type(&mut self) -> ChannelType {
|
||||
ChannelType::DirectMessage
|
||||
}
|
||||
@@ -153,6 +161,14 @@ async fn validate_group_permissions() {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
async fn do_we_have_publish_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn do_we_have_receive_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn get_channel_type(&mut self) -> ChannelType {
|
||||
ChannelType::Group
|
||||
}
|
||||
@@ -254,6 +270,14 @@ async fn validate_server_permissions() {
|
||||
false
|
||||
}
|
||||
|
||||
async fn do_we_have_publish_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn do_we_have_receive_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn get_channel_type(&mut self) -> ChannelType {
|
||||
ChannelType::ServerChannel
|
||||
}
|
||||
@@ -346,6 +370,14 @@ async fn validate_timed_out_member() {
|
||||
true
|
||||
}
|
||||
|
||||
async fn do_we_have_publish_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn do_we_have_receive_overwrites(&mut self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
async fn get_channel_type(&mut self) -> ChannelType {
|
||||
ChannelType::ServerChannel
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@ pub trait PermissionQuery {
|
||||
/// Is our perspective user timed out on this server?
|
||||
async fn are_we_timed_out(&mut self) -> bool;
|
||||
|
||||
/// Is the member muted?
|
||||
async fn do_we_have_publish_overwrites(&mut self) -> bool;
|
||||
|
||||
/// Is the member deafend?
|
||||
async fn do_we_have_receive_overwrites(&mut self) -> bool;
|
||||
|
||||
// * For calculating channel permission
|
||||
|
||||
/// Get the type of the channel
|
||||
|
||||
Reference in New Issue
Block a user