From d2958053c170f87eb817db737d8ffcbea6db47d9 Mon Sep 17 00:00:00 2001 From: Nick Krantz Date: Thu, 29 May 2025 11:04:33 -0500 Subject: [PATCH] only send notifications per user for each notification --- .../MarkNotificationsForTaskAsDeletedCommand.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Core/Vault/Commands/MarkNotificationsForTaskAsDeletedCommand.cs b/src/Core/Vault/Commands/MarkNotificationsForTaskAsDeletedCommand.cs index 4482107a89..33bfaaa6f2 100644 --- a/src/Core/Vault/Commands/MarkNotificationsForTaskAsDeletedCommand.cs +++ b/src/Core/Vault/Commands/MarkNotificationsForTaskAsDeletedCommand.cs @@ -43,19 +43,22 @@ public class MarkNotificationsForTaskAsDeletedCommand : IMarkNotificationsForTas DeletedDate = DateTime.UtcNow }; - var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus); + await _notificationStatusRepository.CreateAsync(notificationStatus); - await _pushNotificationService.PushNotificationStatusAsync(notification, newNotificationStatus); } else { notificationStatus.DeletedDate = DateTime.UtcNow; await _notificationStatusRepository.UpdateAsync(notificationStatus); - - await _pushNotificationService.PushNotificationStatusAsync(notification, notificationStatus); } + } + // For each user, send a push notification so they can update their local tasks + var uniqueUserIds = notifications.Select(n => n.UserId).Where(u => u.HasValue).Distinct(); + foreach (var userId in uniqueUserIds) + { + await _pushNotificationService.PushPendingSecurityTasksAsync((Guid)userId); } } }