1
0
mirror of https://github.com/bitwarden/server synced 2026-02-28 02:13:19 +00:00

[PM-32764] Archive Sync Notifications Double Sync Solve (#7093)

* exclude double sync on archive and unarchive
This commit is contained in:
Jason Ng
2026-02-27 12:28:31 -05:00
committed by GitHub
parent 1961bb5cc9
commit 938b598a82
5 changed files with 10 additions and 8 deletions

View File

@@ -87,7 +87,7 @@ public interface IPushNotificationService
ExcludeCurrentContext = true,
});
Task PushSyncCiphersAsync(Guid userId)
Task PushSyncCiphersAsync(Guid userId, bool excludeCurrentContext = false)
=> PushAsync(new PushNotification<UserPushNotification>
{
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)

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -43,7 +43,7 @@ public class ArchiveCiphersCommandTest
: ids.All(id => cipherList.Contains(cipher))),
user.Id);
await sutProvider.GetDependency<IPushNotificationService>().Received(pushNotificationsCalls)
.PushSyncCiphersAsync(user.Id);
.PushSyncCiphersAsync(user.Id, true);
}
[Theory]

View File

@@ -43,7 +43,7 @@ public class UnarchiveCiphersCommandTest
: ids.All(id => cipherList.Contains(cipher))),
user.Id);
await sutProvider.GetDependency<IPushNotificationService>().Received(pushNotificationsCalls)
.PushSyncCiphersAsync(user.Id);
.PushSyncCiphersAsync(user.Id, true);
}
[Theory]