User
Fix: Notification, Remove toggle, add kanban board to menu, fix project ID to project name
64a3c1d
Raw
History Blame Contribute Delete
1.01 kB
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using TaskTrackingSystem.WebApi.Infrastructure;
namespace TaskTrackingSystem.WebApi.Features.Notification;
[Authorize]
public class NotificationHub : Hub
{
public static string GetUserGroupName(long userId) => $"notification-user-{userId}";
public override async global::System.Threading.Tasks.Task OnConnectedAsync()
{
var userId = Context.User?.GetUserId() ?? 0;
if (userId > 0)
{
await Groups.AddToGroupAsync(Context.ConnectionId, GetUserGroupName(userId));
}
await base.OnConnectedAsync();
}
public override async global::System.Threading.Tasks.Task OnDisconnectedAsync(Exception? exception)
{
var userId = Context.User?.GetUserId() ?? 0;
if (userId > 0)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, GetUserGroupName(userId));
}
await base.OnDisconnectedAsync(exception);
}
}