From c09db88f4e4dc31d7294470464deda72cb976ead Mon Sep 17 00:00:00 2001 From: matlink Date: Sun, 6 Aug 2023 21:33:14 +0200 Subject: [PATCH] Notify groups only when enabled --- src/db/models/cipher.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs index bda7645f..ec5c5d6a 100644 --- a/src/db/models/cipher.rs +++ b/src/db/models/cipher.rs @@ -273,15 +273,18 @@ impl Cipher { None => { // Belongs to Organization, need to update affected users if let Some(ref org_uuid) = self.organization_uuid { - for user_org in UserOrganization::find_by_cipher_and_org(&self.uuid, org_uuid, conn).await.iter() { - User::update_uuid_revision(&user_org.user_uuid, conn).await; - user_uuids.push(user_org.user_uuid.clone()); + // users having access to the collection + let mut collection_users = + UserOrganization::find_by_cipher_and_org(&self.uuid, org_uuid, conn).await; + if CONFIG.org_groups_enabled() { + // members of a group having access to the collection + let group_users = + UserOrganization::find_by_cipher_and_org_with_group(&self.uuid, org_uuid, conn).await; + collection_users.extend(group_users); } - for user_org in - UserOrganization::find_by_cipher_and_org_with_group(&self.uuid, org_uuid, conn).await.iter() - { + for user_org in collection_users { User::update_uuid_revision(&user_org.user_uuid, conn).await; - user_uuids.push(user_org.user_uuid.clone()); + user_uuids.push(user_org.user_uuid.clone()) } } }