mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 01:22:50 -05:00
PM-10600: Send push notification on notification creation
This commit is contained in:
@ -4,6 +4,7 @@ using Bit.Core.NotificationCenter.Authorization;
|
||||
using Bit.Core.NotificationCenter.Commands.Interfaces;
|
||||
using Bit.Core.NotificationCenter.Entities;
|
||||
using Bit.Core.NotificationCenter.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
@ -14,14 +15,17 @@ public class CreateNotificationCommand : ICreateNotificationCommand
|
||||
private readonly ICurrentContext _currentContext;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly INotificationRepository _notificationRepository;
|
||||
private readonly IPushNotificationService _pushNotificationService;
|
||||
|
||||
public CreateNotificationCommand(ICurrentContext currentContext,
|
||||
IAuthorizationService authorizationService,
|
||||
INotificationRepository notificationRepository)
|
||||
INotificationRepository notificationRepository,
|
||||
IPushNotificationService pushNotificationService)
|
||||
{
|
||||
_currentContext = currentContext;
|
||||
_authorizationService = authorizationService;
|
||||
_notificationRepository = notificationRepository;
|
||||
_pushNotificationService = pushNotificationService;
|
||||
}
|
||||
|
||||
public async Task<Notification> CreateAsync(Notification notification)
|
||||
@ -31,6 +35,10 @@ public class CreateNotificationCommand : ICreateNotificationCommand
|
||||
await _authorizationService.AuthorizeOrThrowAsync(_currentContext.HttpContext.User, notification,
|
||||
NotificationOperations.Create);
|
||||
|
||||
return await _notificationRepository.CreateAsync(notification);
|
||||
var newNotification = await _notificationRepository.CreateAsync(notification);
|
||||
|
||||
await _pushNotificationService.PushSyncNotificationAsync(newNotification);
|
||||
|
||||
return newNotification;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user