mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-28 19:34:23 +01:00
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Data;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace BTCPayServer.Events.Notifications
|
|
{
|
|
public class NotificationSender
|
|
{
|
|
private readonly UserManager<ApplicationUser> _userManager;
|
|
private readonly EventAggregator _eventAggregator;
|
|
|
|
public NotificationSender(UserManager<ApplicationUser> userManager, EventAggregator eventAggregator)
|
|
{
|
|
_userManager = userManager;
|
|
_eventAggregator = eventAggregator;
|
|
}
|
|
|
|
internal async Task NoticeNewVersionAsync(string version)
|
|
{
|
|
var admins = await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin);
|
|
var adminUids = admins.Select(a => a.Id).ToArray();
|
|
var evt = new NotificationEvent
|
|
{
|
|
ApplicationUserIds = adminUids,
|
|
Notification = new NewVersionNotification
|
|
{
|
|
Version = version
|
|
}
|
|
};
|
|
|
|
_eventAggregator.Publish(evt);
|
|
}
|
|
}
|
|
}
|