1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00:22:50 -05:00

PM-10564: Wrong push notification received when notification updated.

This commit is contained in:
Maciej Zieniuk
2024-11-21 22:21:09 +00:00
parent d9711b6031
commit 6e69c8a0ce
6 changed files with 22 additions and 22 deletions

View File

@ -65,7 +65,7 @@ public class MarkNotificationDeletedCommand : IMarkNotificationDeletedCommand
var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus); var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus);
await _pushNotificationService.PushSyncNotificationCreateAsync(notification, newNotificationStatus); await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus);
} }
else else
{ {
@ -76,7 +76,7 @@ public class MarkNotificationDeletedCommand : IMarkNotificationDeletedCommand
await _notificationStatusRepository.UpdateAsync(notificationStatus); await _notificationStatusRepository.UpdateAsync(notificationStatus);
await _pushNotificationService.PushSyncNotificationCreateAsync(notification, notificationStatus); await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, notificationStatus);
} }
} }
} }

View File

@ -65,7 +65,7 @@ public class MarkNotificationReadCommand : IMarkNotificationReadCommand
var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus); var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus);
await _pushNotificationService.PushSyncNotificationCreateAsync(notification, newNotificationStatus); await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus);
} }
else else
{ {
@ -76,7 +76,7 @@ public class MarkNotificationReadCommand : IMarkNotificationReadCommand
await _notificationStatusRepository.UpdateAsync(notificationStatus); await _notificationStatusRepository.UpdateAsync(notificationStatus);
await _pushNotificationService.PushSyncNotificationCreateAsync(notification, notificationStatus); await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, notificationStatus);
} }
} }
} }

View File

@ -48,6 +48,6 @@ public class UpdateNotificationCommand : IUpdateNotificationCommand
await _notificationRepository.ReplaceAsync(notification); await _notificationRepository.ReplaceAsync(notification);
await _pushNotificationService.PushSyncNotificationCreateAsync(notification, null); await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, null);
} }
} }

View File

@ -66,7 +66,7 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -80,7 +80,7 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -95,7 +95,7 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -110,7 +110,7 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -125,7 +125,7 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -149,7 +149,7 @@ public class MarkNotificationDeletedCommandTest
.CreateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); .CreateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(1) .Received(1)
.PushSyncNotificationCreateAsync(notification, .PushSyncNotificationUpdateAsync(notification,
Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
} }
@ -167,7 +167,7 @@ public class MarkNotificationDeletedCommandTest
.UpdateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns))); .UpdateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(1) .Received(1)
.PushSyncNotificationCreateAsync(notification, .PushSyncNotificationUpdateAsync(notification,
Arg.Do<NotificationStatus?>(ns => AssertNotificationStatus(notificationStatus, ns))); Arg.Do<NotificationStatus?>(ns => AssertNotificationStatus(notificationStatus, ns)));
} }

View File

@ -66,7 +66,7 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -80,7 +80,7 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -95,7 +95,7 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -110,7 +110,7 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -125,7 +125,7 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -149,7 +149,7 @@ public class MarkNotificationReadCommandTest
.CreateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); .CreateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(1) .Received(1)
.PushSyncNotificationCreateAsync(notification, .PushSyncNotificationUpdateAsync(notification,
Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
} }
@ -167,7 +167,7 @@ public class MarkNotificationReadCommandTest
.UpdateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns))); .UpdateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(1) .Received(1)
.PushSyncNotificationCreateAsync(notification, .PushSyncNotificationUpdateAsync(notification,
Arg.Do<NotificationStatus?>(ns => AssertNotificationStatus(notificationStatus, ns))); Arg.Do<NotificationStatus?>(ns => AssertNotificationStatus(notificationStatus, ns)));
} }

View File

@ -48,7 +48,7 @@ public class UpdateNotificationCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(notification)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(notification));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -62,7 +62,7 @@ public class UpdateNotificationCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(notification)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(notification));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(0) .Received(0)
.PushSyncNotificationCreateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>()); .PushSyncNotificationUpdateAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus?>());
} }
[Theory] [Theory]
@ -100,6 +100,6 @@ public class UpdateNotificationCommandTest
DateTime.UtcNow - n.RevisionDate < TimeSpan.FromMinutes(1))); DateTime.UtcNow - n.RevisionDate < TimeSpan.FromMinutes(1)));
await sutProvider.GetDependency<IPushNotificationService>() await sutProvider.GetDependency<IPushNotificationService>()
.Received(1) .Received(1)
.PushSyncNotificationCreateAsync(notification, null); .PushSyncNotificationUpdateAsync(notification, null);
} }
} }