Skip to content

Commit

Permalink
remove skip custom resolved fit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
www committed Nov 16, 2024
1 parent 9eadbb9 commit 2f592bf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
37 changes: 14 additions & 23 deletions core/rust.permissions.checks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,23 @@ pub async fn get_user_kittycat_perms(
roles: &FixedArray<serenity::all::RoleId>,
) -> Result<Vec<kittycat::perms::Permission>, silverpelt::Error> {
if let Some(ref custom_resolved_kittycat_perms) = opts.custom_resolved_kittycat_perms {
if !opts.skip_custom_resolved_fit_checks {
let kc_perms = silverpelt::member_permission_calc::get_kittycat_perms(
&mut *pool.acquire().await?,
guild_id,
guild_owner_id,
user_id,
roles,
)
.await?;
let kc_perms = silverpelt::member_permission_calc::get_kittycat_perms(
&mut *pool.acquire().await?,
guild_id,
guild_owner_id,
user_id,
roles,
)
.await?;

let mut resolved_perms = Vec::new();
for perm in custom_resolved_kittycat_perms {
if kittycat::perms::has_perm(&kc_perms, perm) {
resolved_perms.push(perm.clone());
}
let mut resolved_perms = Vec::new();
for perm in custom_resolved_kittycat_perms {
if kittycat::perms::has_perm(&kc_perms, perm) {
resolved_perms.push(perm.clone());
}

Ok(resolved_perms)
} else {
Ok(custom_resolved_kittycat_perms.to_vec())
}

Ok(resolved_perms)
} else {
Ok(silverpelt::member_permission_calc::get_kittycat_perms(
&mut *pool.acquire().await?,
Expand All @@ -190,10 +186,6 @@ pub struct CheckCommandOptions {
#[serde(default)]
pub ignore_command_disabled: bool,

/// Skip custom resolved kittycat permission fit 'checks' (AKA does the user have the actual permissions ofthe custom resolved permissions)
#[serde(default)]
pub skip_custom_resolved_fit_checks: bool,

/// What custom resolved permissions to use for the user. API needs this for limiting the permissions of a user
#[serde(default)]
pub custom_resolved_kittycat_perms: Option<Vec<Permission>>,
Expand All @@ -218,7 +210,6 @@ impl Default for CheckCommandOptions {
ignore_module_disabled: false,
ignore_command_disabled: false,
custom_resolved_kittycat_perms: None,
skip_custom_resolved_fit_checks: false,
custom_command_configuration: None,
custom_module_configuration: None,
channel_id: None,
Expand Down
3 changes: 0 additions & 3 deletions core/rust.rpc_server.bot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ async fn check_command_permission(
}),
custom_command_configuration: opts.custom_command_configuration.map(|x| *x),
custom_module_configuration: opts.custom_module_configuration.map(|x| *x),
skip_custom_resolved_fit_checks: flags.contains(
crate::types::RpcCheckCommandOptionsFlags::SKIP_CUSTOM_RESOLVED_FIT_CHECKS,
),
channel_id: opts.channel_id,
},
)
Expand Down
2 changes: 0 additions & 2 deletions core/rust.rpc_server.bot/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ bitflags::bitflags! {
const IGNORE_MODULE_DISABLED = 1 << 2;
/// Whether or not to ignore the fact that the command is disabled in the guild
const IGNORE_COMMAND_DISABLED = 1 << 3;
/// Skip custom resolved kittycat permission fit 'checks' (AKA does the user have the actual permissions ofthe custom resolved permissions)
const SKIP_CUSTOM_RESOLVED_FIT_CHECKS = 1 << 4;
}
}

Expand Down
2 changes: 1 addition & 1 deletion infra/Sandwich-Daemon
5 changes: 2 additions & 3 deletions services/go.api/rpc_messages/rpc_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ type SettingsOperationRequest struct {
type RpcCheckCommandOptionsFlag uint8

const (
RpcCheckCommandOptionsFlagIgnoreModuleDisabled RpcCheckCommandOptionsFlag = 1 << 2
RpcCheckCommandOptionsFlagIgnoreCommandDisabled RpcCheckCommandOptionsFlag = 1 << 3
RpcCheckCommandOptionsFlagSkipCustomResolvedFitChecks RpcCheckCommandOptionsFlag = 1 << 4
RpcCheckCommandOptionsFlagIgnoreModuleDisabled RpcCheckCommandOptionsFlag = 1 << 2
RpcCheckCommandOptionsFlagIgnoreCommandDisabled RpcCheckCommandOptionsFlag = 1 << 3
)

type RpcCheckCommandOptions struct {
Expand Down

0 comments on commit 2f592bf

Please sign in to comment.