using EnotaryoPH.Web.Common.Hubs;
using Microsoft.AspNetCore.SignalR;

namespace EnotaryoPH.Web.Common.Services
{
    public class NotificationService : INotificationService
    {
        private readonly IHubContext<NotificationHub> _hubContext;

        public NotificationService(IHubContext<NotificationHub> hubContext) => _hubContext = hubContext;

        public async Task NotifyAllAsync(string message) => await _hubContext.Clients.All.SendAsync("ReceiveUserNotification", message);

        public async Task NotifyUserAsync(string message, string userID) => await NotifyUsersAsync(message, userID);

        public async Task NotifyUsersAsync(string message, params string[] userIDs) => await _hubContext.Clients.Users(userIDs).SendAsync("ReceiveUserNotification", message);
    }
}