mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
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.
This commit is contained in:
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user