diff --git a/src/Core/Platform/Push/IPushNotificationService.cs b/src/Core/Platform/Push/IPushNotificationService.cs index b6d7d4d416..125057be1f 100644 --- a/src/Core/Platform/Push/IPushNotificationService.cs +++ b/src/Core/Platform/Push/IPushNotificationService.cs @@ -87,7 +87,7 @@ public interface IPushNotificationService ExcludeCurrentContext = true, }); - Task PushSyncCiphersAsync(Guid userId) + Task PushSyncCiphersAsync(Guid userId, bool excludeCurrentContext = false) => PushAsync(new PushNotification { Type = PushType.SyncCiphers, @@ -100,7 +100,7 @@ public interface IPushNotificationService Date = TimeProvider.GetUtcNow().UtcDateTime, #pragma warning restore BWP0001 // Type or member is obsolete }, - ExcludeCurrentContext = false, + ExcludeCurrentContext = excludeCurrentContext, }); Task PushSyncVaultAsync(Guid userId) diff --git a/src/Core/Vault/Commands/ArchiveCiphersCommand.cs b/src/Core/Vault/Commands/ArchiveCiphersCommand.cs index 0a84dd7fa7..590c93e534 100644 --- a/src/Core/Vault/Commands/ArchiveCiphersCommand.cs +++ b/src/Core/Vault/Commands/ArchiveCiphersCommand.cs @@ -52,9 +52,10 @@ public class ArchiveCiphersCommand : IArchiveCiphersCommand }); // Will not log an event because the archive feature is limited to individual ciphers, and event logs only apply to organization ciphers. - // Add event logging here if this is expanded to organization ciphers in the future. - await _pushService.PushSyncCiphersAsync(archivingUserId); + // ExcludeCurrentContext to avoid double syncing when archiving a cipher + + await _pushService.PushSyncCiphersAsync(archivingUserId, true); return archivingCiphers; } diff --git a/src/Core/Vault/Commands/UnarchiveCiphersCommand.cs b/src/Core/Vault/Commands/UnarchiveCiphersCommand.cs index 3a513db3f3..9d910012bb 100644 --- a/src/Core/Vault/Commands/UnarchiveCiphersCommand.cs +++ b/src/Core/Vault/Commands/UnarchiveCiphersCommand.cs @@ -51,9 +51,10 @@ public class UnarchiveCiphersCommand : IUnarchiveCiphersCommand c.ArchivedDate = null; }); // Will not log an event because the archive feature is limited to individual ciphers, and event logs only apply to organization ciphers. - // Add event logging here if this is expanded to organization ciphers in the future. - await _pushService.PushSyncCiphersAsync(unarchivingUserId); + // ExcludeCurrentContext to avoid double syncing when unarchiving a cipher + + await _pushService.PushSyncCiphersAsync(unarchivingUserId, true); return unarchivingCiphers; } diff --git a/test/Core.Test/Vault/Commands/ArchiveCiphersCommandTest.cs b/test/Core.Test/Vault/Commands/ArchiveCiphersCommandTest.cs index 31a96f3eca..343ad48c9b 100644 --- a/test/Core.Test/Vault/Commands/ArchiveCiphersCommandTest.cs +++ b/test/Core.Test/Vault/Commands/ArchiveCiphersCommandTest.cs @@ -43,7 +43,7 @@ public class ArchiveCiphersCommandTest : ids.All(id => cipherList.Contains(cipher))), user.Id); await sutProvider.GetDependency().Received(pushNotificationsCalls) - .PushSyncCiphersAsync(user.Id); + .PushSyncCiphersAsync(user.Id, true); } [Theory] diff --git a/test/Core.Test/Vault/Commands/UnarchiveCiphersCommandTest.cs b/test/Core.Test/Vault/Commands/UnarchiveCiphersCommandTest.cs index 084a503cf1..86531ea70a 100644 --- a/test/Core.Test/Vault/Commands/UnarchiveCiphersCommandTest.cs +++ b/test/Core.Test/Vault/Commands/UnarchiveCiphersCommandTest.cs @@ -43,7 +43,7 @@ public class UnarchiveCiphersCommandTest : ids.All(id => cipherList.Contains(cipher))), user.Id); await sutProvider.GetDependency().Received(pushNotificationsCalls) - .PushSyncCiphersAsync(user.Id); + .PushSyncCiphersAsync(user.Id, true); } [Theory]