Browse Source

fix: clippy refactors

pull/7452/head
Raphaël Roumezin 1 day ago
parent
commit
f05f9eddf3
  1. 2
      src/api/core/organizations.rs
  2. 2
      src/db/models/cipher.rs
  3. 9
      src/db/models/organization.rs

2
src/api/core/organizations.rs

@ -767,7 +767,7 @@ async fn delete_organization_collection_impl(
if org_id != &headers.org_id { if org_id != &headers.org_id {
err!("Organization not found", "Organization id's do not match"); err!("Organization not found", "Organization id's do not match");
} }
let Some(org_settings) = Organization::find_collection_settings_by_uuid(&org_id, &conn).await else { let Some(org_settings) = Organization::find_collection_settings_by_uuid(org_id, conn).await else {
err!("Can't find organization details") err!("Can't find organization details")
}; };

2
src/db/models/cipher.rs

@ -727,7 +727,7 @@ impl Cipher {
pub async fn is_deletable_by_user(&self, user_uuid: &UserId, conn: &DbConn) -> bool { pub async fn is_deletable_by_user(&self, user_uuid: &UserId, conn: &DbConn) -> bool {
let manage_required = match self.organization_uuid { let manage_required = match self.organization_uuid {
Some(ref org_id) => match Organization::find_collection_settings_by_uuid(&org_id, &conn).await { Some(ref org_id) => match Organization::find_collection_settings_by_uuid(org_id, conn).await {
Some(settings) => settings.limit_item_deletion, Some(settings) => settings.limit_item_deletion,
None => false, None => false,
}, },

9
src/db/models/organization.rs

@ -37,6 +37,7 @@ use super::{
#[derive(Debug, Clone, Copy, FromSqlRow, AsExpression)] #[derive(Debug, Clone, Copy, FromSqlRow, AsExpression)]
#[diesel(sql_type = SmallInt)] #[diesel(sql_type = SmallInt)]
#[allow(clippy::struct_excessive_bools)]
pub struct OrganizationCollectionSettings { pub struct OrganizationCollectionSettings {
pub allow_admin_access_to_all_collection_items: bool, pub allow_admin_access_to_all_collection_items: bool,
pub limit_collection_creation: bool, pub limit_collection_creation: bool,
@ -46,10 +47,10 @@ pub struct OrganizationCollectionSettings {
impl From<&OrganizationCollectionSettings> for i16 { impl From<&OrganizationCollectionSettings> for i16 {
fn from(value: &OrganizationCollectionSettings) -> Self { fn from(value: &OrganizationCollectionSettings) -> Self {
(0b1 * (value.allow_admin_access_to_all_collection_items as i16)) i16::from(value.allow_admin_access_to_all_collection_items)
| (0b10 * (value.limit_collection_creation as i16)) | (0b10 * i16::from(value.limit_collection_creation))
| (0b100 * (value.limit_collection_deletion as i16)) | (0b100 * i16::from(value.limit_collection_deletion))
| (0b1000 * (value.limit_item_deletion as i16)) | (0b1000 * i16::from(value.limit_item_deletion))
} }
} }

Loading…
Cancel
Save