1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

PM-10600: Revert global push notifications

This commit is contained in:
Maciej Zieniuk
2024-10-22 18:27:18 +01:00
parent 4173fa8e81
commit 3035abfa30
12 changed files with 10 additions and 115 deletions

View File

@ -171,7 +171,6 @@ public class AzureQueuePushNotificationService : IPushNotificationService
var message = new SyncNotificationPushNotification
{
Id = notification.Id,
Global = notification.Global,
UserId = notification.UserId,
OrganizationId = notification.OrganizationId,
ClientType = notification.ClientType,
@ -229,7 +228,4 @@ public class AzureQueuePushNotificationService : IPushNotificationService
// Noop
return Task.FromResult(0);
}
public Task SendPayloadToEveryoneAsync(PushType type, object payload, string identifier, string deviceId = null,
ClientType? clientType = null) => Task.CompletedTask;
}

View File

@ -184,13 +184,6 @@ public class MultiServicePushNotificationService : IPushNotificationService
return Task.CompletedTask;
}
public Task SendPayloadToEveryoneAsync(PushType type, object payload, string identifier, string deviceId = null,
ClientType? clientType = null)
{
PushToServices((s) => s.SendPayloadToEveryoneAsync(type, payload, identifier, deviceId, clientType));
return Task.CompletedTask;
}
private void PushToServices(Func<IPushNotificationService, Task> pushFunc)
{
if (_services != null)

View File

@ -199,18 +199,13 @@ public class NotificationHubPushNotificationService : IPushNotificationService
var message = new SyncNotificationPushNotification
{
Id = notification.Id,
Global = notification.Global,
UserId = notification.UserId,
OrganizationId = notification.OrganizationId,
ClientType = notification.ClientType,
RevisionDate = notification.RevisionDate
};
if (notification.Global)
{
await SendPayloadToEveryoneAsync(PushType.SyncNotification, message, true, notification.ClientType);
}
else if (notification.UserId.HasValue)
if (notification.UserId.HasValue)
{
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true,
notification.ClientType);
@ -243,13 +238,6 @@ public class NotificationHubPushNotificationService : IPushNotificationService
clientType: clientType);
}
private async Task SendPayloadToEveryoneAsync(PushType type, object payload, bool excludeCurrentContext,
ClientType? clientType = null)
{
await SendPayloadToEveryoneAsync(type, payload, GetContextIdentifier(excludeCurrentContext),
clientType: clientType);
}
public async Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier,
string deviceId = null, ClientType? clientType = null)
{
@ -272,17 +260,6 @@ public class NotificationHubPushNotificationService : IPushNotificationService
}
}
public async Task SendPayloadToEveryoneAsync(PushType type, object payload, string identifier,
string deviceId = null, ClientType? clientType = null)
{
var tag = BuildTag($"template:payload", identifier, clientType);
await SendPayloadAsync(tag, type, payload);
if (InstallationDeviceEntity.IsInstallationDeviceId(deviceId))
{
await _installationDeviceRepository.UpsertAsync(new InstallationDeviceEntity(deviceId));
}
}
private string GetContextIdentifier(bool excludeCurrentContext)
{
if (!excludeCurrentContext)

View File

@ -178,7 +178,6 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
var message = new SyncNotificationPushNotification
{
Id = notification.Id,
Global = notification.Global,
UserId = notification.UserId,
OrganizationId = notification.OrganizationId,
ClientType = notification.ClientType,
@ -235,7 +234,4 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
// Noop
return Task.FromResult(0);
}
public Task SendPayloadToEveryoneAsync(PushType type, object payload, string identifier, string deviceId = null,
ClientType? clientType = null) => Task.CompletedTask;
}

View File

@ -194,18 +194,13 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
var message = new SyncNotificationPushNotification
{
Id = notification.Id,
Global = notification.Global,
UserId = notification.UserId,
OrganizationId = notification.OrganizationId,
ClientType = notification.ClientType,
RevisionDate = notification.RevisionDate
};
if (notification.Global)
{
await SendPayloadToEveryoneAsync(PushType.SyncNotification, message, true, notification.ClientType);
}
else if (notification.UserId.HasValue)
if (notification.UserId.HasValue)
{
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true,
notification.ClientType);
@ -247,21 +242,6 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
await SendAsync(HttpMethod.Post, "push/send", request);
}
private async Task SendPayloadToEveryoneAsync(PushType type, object payload, bool excludeCurrentContext,
ClientType? clientType = null)
{
var request = new PushSendRequestModel
{
Global = true,
Type = type,
Payload = payload,
ClientType = clientType
};
await AddCurrentContextAsync(request, excludeCurrentContext);
await SendAsync(HttpMethod.Post, "push/send", request);
}
private async Task AddCurrentContextAsync(PushSendRequestModel request, bool addIdentifier)
{
var currentContext =
@ -292,10 +272,4 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
{
throw new NotImplementedException();
}
public Task SendPayloadToEveryoneAsync(PushType type, object payload, string identifier, string deviceId = null,
ClientType? clientType = null)
{
throw new NotImplementedException();
}
}