From d142af07bf74ddd990bbba47a3e847c69cac5e94 Mon Sep 17 00:00:00 2001 From: Maciej Zieniuk Date: Tue, 5 Nov 2024 14:59:27 +0000 Subject: [PATCH] PM-10600: Fix Mobile devices not registering to organization push notifications We only register devices for organization push notifications when the organization is being created. This does not work, since we have a use case (Notification Center) of delivering notifications to all users of organization. This fixes it, by adding the organization id tag when device registers for push notifications. --- .../NotificationHubPushRegistrationService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Core/NotificationHub/NotificationHubPushRegistrationService.cs b/src/Core/NotificationHub/NotificationHubPushRegistrationService.cs index e8067c9eaf..4986061a13 100644 --- a/src/Core/NotificationHub/NotificationHubPushRegistrationService.cs +++ b/src/Core/NotificationHub/NotificationHubPushRegistrationService.cs @@ -13,15 +13,18 @@ public class NotificationHubPushRegistrationService : IPushRegistrationService private readonly IInstallationDeviceRepository _installationDeviceRepository; private readonly INotificationHubPool _notificationHubPool; private readonly IServiceProvider _serviceProvider; + private readonly IOrganizationUserRepository _organizationUserRepository; public NotificationHubPushRegistrationService( IInstallationDeviceRepository installationDeviceRepository, INotificationHubPool notificationHubPool, - IServiceProvider serviceProvider) + IServiceProvider serviceProvider, + IOrganizationUserRepository organizationUserRepository) { _installationDeviceRepository = installationDeviceRepository; _notificationHubPool = notificationHubPool; _serviceProvider = serviceProvider; + _organizationUserRepository = organizationUserRepository; } public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId, @@ -48,6 +51,12 @@ public class NotificationHubPushRegistrationService : IPushRegistrationService installation.Tags.Add("deviceIdentifier:" + identifier); } + foreach (var organizationUserDetails in await _organizationUserRepository.GetManyDetailsByUserAsync( + Guid.Parse(userId), OrganizationUserStatusType.Confirmed)) + { + installation.Tags.Add($"organizationId:{organizationUserDetails.OrganizationId}"); + } + string payloadTemplate = null, messageTemplate = null, badgeMessageTemplate = null; switch (type) {