mirror of
https://github.com/bitwarden/server
synced 2026-01-15 15:03:34 +00:00
PM-10564: Sync notification push type separation for notification updates
Sync notification push type is now used for both Notification create and update. Renamed the event types to specifically mention the purpose of status for notification status updates.
This commit is contained in:
@@ -26,6 +26,6 @@ public enum PushType : byte
|
||||
|
||||
SyncOrganizations = 17,
|
||||
|
||||
SyncNotificationCreate = 18,
|
||||
SyncNotificationUpdate = 19
|
||||
SyncNotification = 18,
|
||||
SyncNotificationStatus = 19
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CreateNotificationCommand : ICreateNotificationCommand
|
||||
|
||||
var newNotification = await _notificationRepository.CreateAsync(notification);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationCreateAsync(newNotification);
|
||||
await _pushNotificationService.PushSyncNotificationAsync(newNotification);
|
||||
|
||||
return newNotification;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CreateNotificationStatusCommand : ICreateNotificationStatusCommand
|
||||
|
||||
var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus);
|
||||
await _pushNotificationService.PushSyncNotificationStatusAsync(notification, newNotificationStatus);
|
||||
|
||||
return newNotificationStatus;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MarkNotificationDeletedCommand : IMarkNotificationDeletedCommand
|
||||
|
||||
var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus);
|
||||
await _pushNotificationService.PushSyncNotificationStatusAsync(notification, newNotificationStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public class MarkNotificationDeletedCommand : IMarkNotificationDeletedCommand
|
||||
|
||||
await _notificationStatusRepository.UpdateAsync(notificationStatus);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, notificationStatus);
|
||||
await _pushNotificationService.PushSyncNotificationStatusAsync(notification, notificationStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MarkNotificationReadCommand : IMarkNotificationReadCommand
|
||||
|
||||
var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus);
|
||||
await _pushNotificationService.PushSyncNotificationStatusAsync(notification, newNotificationStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public class MarkNotificationReadCommand : IMarkNotificationReadCommand
|
||||
|
||||
await _notificationStatusRepository.UpdateAsync(notificationStatus);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, notificationStatus);
|
||||
await _pushNotificationService.PushSyncNotificationStatusAsync(notification, notificationStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,6 @@ public class UpdateNotificationCommand : IUpdateNotificationCommand
|
||||
|
||||
await _notificationRepository.ReplaceAsync(notification);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, null);
|
||||
await _pushNotificationService.PushSyncNotificationAsync(notification);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class NotificationHubPushNotificationService : IPushNotificationService
|
||||
await PushAuthRequestAsync(authRequest, PushType.AuthRequestResponse);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationCreateAsync(Notification notification)
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -195,17 +195,17 @@ public class NotificationHubPushNotificationService : IPushNotificationService
|
||||
|
||||
if (notification.UserId.HasValue)
|
||||
{
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationCreate, message, true,
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true,
|
||||
notification.ClientType);
|
||||
}
|
||||
else if (notification.OrganizationId.HasValue)
|
||||
{
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationCreate, message,
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotification, message,
|
||||
true, notification.ClientType);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus)
|
||||
public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -214,18 +214,18 @@ public class NotificationHubPushNotificationService : IPushNotificationService
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
RevisionDate = notification.RevisionDate,
|
||||
ReadDate = notificationStatus?.ReadDate,
|
||||
DeletedDate = notificationStatus?.DeletedDate
|
||||
ReadDate = notificationStatus.ReadDate,
|
||||
DeletedDate = notificationStatus.DeletedDate
|
||||
};
|
||||
|
||||
if (notification.UserId.HasValue)
|
||||
{
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationUpdate, message, true,
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationStatus, message, true,
|
||||
notification.ClientType);
|
||||
}
|
||||
else if (notification.OrganizationId.HasValue)
|
||||
{
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationUpdate, message,
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationStatus, message,
|
||||
true, notification.ClientType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public interface IPushNotificationService
|
||||
Task PushSyncSendCreateAsync(Send send);
|
||||
Task PushSyncSendUpdateAsync(Send send);
|
||||
Task PushSyncSendDeleteAsync(Send send);
|
||||
Task PushSyncNotificationCreateAsync(Notification notification);
|
||||
Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus);
|
||||
Task PushSyncNotificationAsync(Notification notification);
|
||||
Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus);
|
||||
Task PushAuthRequestAsync(AuthRequest authRequest);
|
||||
Task PushAuthRequestResponseAsync(AuthRequest authRequest);
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class AzureQueuePushNotificationService : IPushNotificationService
|
||||
await PushSendAsync(send, PushType.SyncSendDelete);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationCreateAsync(Notification notification)
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -176,10 +176,10 @@ public class AzureQueuePushNotificationService : IPushNotificationService
|
||||
RevisionDate = notification.RevisionDate
|
||||
};
|
||||
|
||||
await SendMessageAsync(PushType.SyncNotificationCreate, message, true);
|
||||
await SendMessageAsync(PushType.SyncNotification, message, true);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus)
|
||||
public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -188,11 +188,11 @@ public class AzureQueuePushNotificationService : IPushNotificationService
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
RevisionDate = notification.RevisionDate,
|
||||
ReadDate = notificationStatus?.ReadDate,
|
||||
DeletedDate = notificationStatus?.DeletedDate
|
||||
ReadDate = notificationStatus.ReadDate,
|
||||
DeletedDate = notificationStatus.DeletedDate
|
||||
};
|
||||
|
||||
await SendMessageAsync(PushType.SyncNotificationUpdate, message, true);
|
||||
await SendMessageAsync(PushType.SyncNotificationStatus, message, true);
|
||||
}
|
||||
|
||||
private async Task PushSendAsync(Send send, PushType type)
|
||||
|
||||
@@ -146,15 +146,15 @@ public class MultiServicePushNotificationService : IPushNotificationService
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
public Task PushSyncNotificationCreateAsync(Notification notification)
|
||||
public Task PushSyncNotificationAsync(Notification notification)
|
||||
{
|
||||
PushToServices((s) => s.PushSyncNotificationCreateAsync(notification));
|
||||
PushToServices((s) => s.PushSyncNotificationAsync(notification));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus)
|
||||
public Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||
{
|
||||
PushToServices((s) => s.PushSyncNotificationUpdateAsync(notification, notificationStatus));
|
||||
PushToServices((s) => s.PushSyncNotificationStatusAsync(notification, notificationStatus));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
|
||||
await PushSendAsync(send, PushType.SyncSendDelete);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationCreateAsync(Notification notification)
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -183,10 +183,10 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
|
||||
RevisionDate = notification.RevisionDate
|
||||
};
|
||||
|
||||
await SendMessageAsync(PushType.SyncNotificationCreate, message, true);
|
||||
await SendMessageAsync(PushType.SyncNotification, message, true);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus)
|
||||
public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -195,11 +195,11 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
RevisionDate = notification.RevisionDate,
|
||||
ReadDate = notificationStatus?.ReadDate,
|
||||
DeletedDate = notificationStatus?.DeletedDate
|
||||
ReadDate = notificationStatus.ReadDate,
|
||||
DeletedDate = notificationStatus.DeletedDate
|
||||
};
|
||||
|
||||
await SendMessageAsync(PushType.SyncNotificationUpdate, message, true);
|
||||
await SendMessageAsync(PushType.SyncNotificationStatus, message, true);
|
||||
}
|
||||
|
||||
private async Task PushSendAsync(Send send, PushType type)
|
||||
|
||||
@@ -190,7 +190,7 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
|
||||
await SendPayloadToUserAsync(authRequest.UserId, type, message, true);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationCreateAsync(Notification notification)
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -203,17 +203,17 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
|
||||
|
||||
if (notification.UserId.HasValue)
|
||||
{
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationCreate, message, true,
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true,
|
||||
notification.ClientType);
|
||||
}
|
||||
else if (notification.OrganizationId.HasValue)
|
||||
{
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationCreate, message,
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotification, message,
|
||||
true, notification.ClientType);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus)
|
||||
public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
{
|
||||
@@ -222,18 +222,18 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
RevisionDate = notification.RevisionDate,
|
||||
ReadDate = notificationStatus?.ReadDate,
|
||||
DeletedDate = notificationStatus?.DeletedDate
|
||||
ReadDate = notificationStatus.ReadDate,
|
||||
DeletedDate = notificationStatus.DeletedDate
|
||||
};
|
||||
|
||||
if (notification.UserId.HasValue)
|
||||
{
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationUpdate, message, true,
|
||||
await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationStatus, message, true,
|
||||
notification.ClientType);
|
||||
}
|
||||
else if (notification.OrganizationId.HasValue)
|
||||
{
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationUpdate, message,
|
||||
await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationStatus, message,
|
||||
true, notification.ClientType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class NoopPushNotificationService : IPushNotificationService
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
public Task PushSyncNotificationCreateAsync(Notification notification) => Task.CompletedTask;
|
||||
public Task PushSyncNotificationAsync(Notification notification) => Task.CompletedTask;
|
||||
|
||||
public Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) => Task.CompletedTask;
|
||||
public Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user