From 3539f7d2bfc345cb5fdcb5bf4f32751c387ef97a Mon Sep 17 00:00:00 2001 From: Cy Okeke Date: Thu, 12 Dec 2024 15:02:29 +0100 Subject: [PATCH] refactor the code and remove private methods --- .../NotificationHubPushNotificationService.cs | 2 +- .../AzureQueuePushNotificationService.cs | 20 ++++++------------- ...NotificationsApiPushNotificationService.cs | 18 +++++------------ .../RelayPushNotificationService.cs | 2 +- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/Core/NotificationHub/NotificationHubPushNotificationService.cs b/src/Core/NotificationHub/NotificationHubPushNotificationService.cs index 4822a010fb..7438e812e0 100644 --- a/src/Core/NotificationHub/NotificationHubPushNotificationService.cs +++ b/src/Core/NotificationHub/NotificationHubPushNotificationService.cs @@ -235,7 +235,7 @@ public class NotificationHubPushNotificationService : IPushNotificationService Enabled = organization.Enabled }; - await SendPayloadToUserAsync(organization.Id, PushType.SyncOrganizationStatusChanged, message, true); + await SendPayloadToOrganizationAsync(organization.Id, PushType.SyncOrganizationStatusChanged, message, false); } private string GetContextIdentifier(bool excludeCurrentContext) diff --git a/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs b/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs index b741965a5e..3daadebf3a 100644 --- a/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs +++ b/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs @@ -225,20 +225,12 @@ public class AzureQueuePushNotificationService : IPushNotificationService public async Task PushSyncOrganizationStatusAsync(Organization organization) { - await PushOrganizationStatusAsync(organization, PushType.SyncOrganizationStatusChanged); - } - - private async Task PushOrganizationStatusAsync(Organization organization, PushType type) - { - if (organization is not null) + var message = new OrganizationStatusPushNotification { - var message = new OrganizationStatusPushNotification - { - OrganizationId = organization.Id, - Enabled = organization.Enabled - }; - - await SendMessageAsync(type, message, true); - } + OrganizationId = organization.Id, + Enabled = organization.Enabled + }; + await SendMessageAsync(PushType.SyncOrganizationStatusChanged, message, false); } + } diff --git a/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs b/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs index f0865659b2..feec75fbe0 100644 --- a/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs +++ b/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs @@ -231,20 +231,12 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService public async Task PushSyncOrganizationStatusAsync(Organization organization) { - await PushOrganizationStatusAsync(organization, PushType.SyncOrganizationStatusChanged); - } - - private async Task PushOrganizationStatusAsync(Organization organization, PushType type) - { - if (organization is not null) + var message = new OrganizationStatusPushNotification { - var message = new OrganizationStatusPushNotification - { - OrganizationId = organization.Id, - Enabled = organization.Enabled - }; + OrganizationId = organization.Id, + Enabled = organization.Enabled + }; - await SendMessageAsync(type, message, true); - } + await SendMessageAsync(PushType.SyncOrganizationStatusChanged, message, false); } } diff --git a/src/Core/Services/Implementations/RelayPushNotificationService.cs b/src/Core/Services/Implementations/RelayPushNotificationService.cs index d2f174b9fb..d725296779 100644 --- a/src/Core/Services/Implementations/RelayPushNotificationService.cs +++ b/src/Core/Services/Implementations/RelayPushNotificationService.cs @@ -261,6 +261,6 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti Enabled = organization.Enabled }; - await SendPayloadToOrganizationAsync(organization.Id, PushType.SyncOrganizationStatusChanged, message, true); + await SendPayloadToOrganizationAsync(organization.Id, PushType.SyncOrganizationStatusChanged, message, false); } }