mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
PM-10600: Push notification with full notification center content.
Notification Center push notification now includes all the fields.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.NotificationCenter.Enums;
|
||||
|
||||
namespace Bit.Core.Models;
|
||||
|
||||
@ -45,14 +46,21 @@ public class SyncSendPushNotification
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
|
||||
public class SyncNotificationPushNotification
|
||||
#nullable enable
|
||||
public class NotificationPushNotification
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Priority Priority { get; set; }
|
||||
public bool Global { get; set; }
|
||||
public ClientType ClientType { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public ClientType ClientType { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? Body { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
#nullable disable
|
||||
|
||||
public class AuthRequestPushNotification
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ public class CreateNotificationCommand : ICreateNotificationCommand
|
||||
|
||||
var newNotification = await _notificationRepository.CreateAsync(notification);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationAsync(newNotification);
|
||||
await _pushNotificationService.PushNotificationAsync(newNotification);
|
||||
|
||||
return newNotification;
|
||||
}
|
||||
|
@ -15,9 +15,8 @@ public class Notification : ITableObject<Guid>
|
||||
public ClientType ClientType { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string? Title { get; set; }
|
||||
public string? Body { get; set; }
|
||||
[MaxLength(256)] public string? Title { get; set; }
|
||||
[MaxLength(3000)] public string? Body { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
|
||||
|
@ -180,14 +180,19 @@ public class NotificationHubPushNotificationService : IPushNotificationService
|
||||
await PushAuthRequestAsync(authRequest, PushType.AuthRequestResponse);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
public async Task PushNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
var message = new NotificationPushNotification
|
||||
{
|
||||
Id = notification.Id,
|
||||
Priority = notification.Priority,
|
||||
Global = notification.Global,
|
||||
ClientType = notification.ClientType,
|
||||
UserId = notification.UserId,
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
Title = notification.Title,
|
||||
Body = notification.Body,
|
||||
CreationDate = notification.CreationDate,
|
||||
RevisionDate = notification.RevisionDate
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ public interface IPushNotificationService
|
||||
Task PushSyncSendCreateAsync(Send send);
|
||||
Task PushSyncSendUpdateAsync(Send send);
|
||||
Task PushSyncSendDeleteAsync(Send send);
|
||||
Task PushSyncNotificationAsync(Notification notification);
|
||||
Task PushNotificationAsync(Notification notification);
|
||||
Task PushAuthRequestAsync(AuthRequest authRequest);
|
||||
Task PushAuthRequestResponseAsync(AuthRequest authRequest);
|
||||
|
||||
|
@ -164,14 +164,19 @@ public class AzureQueuePushNotificationService : IPushNotificationService
|
||||
await PushSendAsync(send, PushType.SyncSendDelete);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
public async Task PushNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
var message = new NotificationPushNotification
|
||||
{
|
||||
Id = notification.Id,
|
||||
Priority = notification.Priority,
|
||||
Global = notification.Global,
|
||||
ClientType = notification.ClientType,
|
||||
UserId = notification.UserId,
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
Title = notification.Title,
|
||||
Body = notification.Body,
|
||||
CreationDate = notification.CreationDate,
|
||||
RevisionDate = notification.RevisionDate
|
||||
};
|
||||
|
||||
|
@ -145,9 +145,9 @@ public class MultiServicePushNotificationService : IPushNotificationService
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
public Task PushSyncNotificationAsync(Notification notification)
|
||||
public Task PushNotificationAsync(Notification notification)
|
||||
{
|
||||
PushToServices((s) => s.PushSyncNotificationAsync(notification));
|
||||
PushToServices((s) => s.PushNotificationAsync(notification));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
@ -173,14 +173,19 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService
|
||||
await PushSendAsync(send, PushType.SyncSendDelete);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
public async Task PushNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
var message = new NotificationPushNotification
|
||||
{
|
||||
Id = notification.Id,
|
||||
Priority = notification.Priority,
|
||||
Global = notification.Global,
|
||||
ClientType = notification.ClientType,
|
||||
UserId = notification.UserId,
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
Title = notification.Title,
|
||||
Body = notification.Body,
|
||||
CreationDate = notification.CreationDate,
|
||||
RevisionDate = notification.RevisionDate
|
||||
};
|
||||
|
||||
|
@ -189,14 +189,19 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti
|
||||
await SendPayloadToUserAsync(authRequest.UserId, type, message, true);
|
||||
}
|
||||
|
||||
public async Task PushSyncNotificationAsync(Notification notification)
|
||||
public async Task PushNotificationAsync(Notification notification)
|
||||
{
|
||||
var message = new SyncNotificationPushNotification
|
||||
var message = new NotificationPushNotification
|
||||
{
|
||||
Id = notification.Id,
|
||||
Priority = notification.Priority,
|
||||
Global = notification.Global,
|
||||
ClientType = notification.ClientType,
|
||||
UserId = notification.UserId,
|
||||
OrganizationId = notification.OrganizationId,
|
||||
ClientType = notification.ClientType,
|
||||
Title = notification.Title,
|
||||
Body = notification.Body,
|
||||
CreationDate = notification.CreationDate,
|
||||
RevisionDate = notification.RevisionDate
|
||||
};
|
||||
|
||||
|
@ -105,5 +105,5 @@ public class NoopPushNotificationService : IPushNotificationService
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
public Task PushSyncNotificationAsync(Notification notification) => Task.CompletedTask;
|
||||
public Task PushNotificationAsync(Notification notification) => Task.CompletedTask;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public static class HubHelpers
|
||||
break;
|
||||
case PushType.SyncNotification:
|
||||
var syncNotification =
|
||||
JsonSerializer.Deserialize<PushNotificationData<SyncNotificationPushNotification>>(
|
||||
JsonSerializer.Deserialize<PushNotificationData<NotificationPushNotification>>(
|
||||
notificationJson, _deserializerOptions);
|
||||
if (syncNotification.Payload.UserId.HasValue)
|
||||
{
|
||||
|
Reference in New Issue
Block a user