feat: implement notification system with repository, service, and controller layers

This commit is contained in:
2026-10-20 16:45:48 +05:30
parent 28c465f59b
commit d1c3d4e22f
10 changed files with 656 additions and 0 deletions
@@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
namespace Distribution.Features.Notifications;
/// <summary>
/// Server → client only. The server pushes a "notification" event to each recipient; clients never
/// invoke hub methods. Users are addressed by their id (see <see cref="NotificationUserIdProvider"/>).
/// </summary>
[Authorize]
public class NotificationHub : Hub
{
public const string Path = "/hubs/notifications";
public const string ClientEvent = "notification";
}
/// <summary>Maps a SignalR connection to the "UserId" claim that <c>AuthMiddleware</c> puts on the principal.</summary>
public class NotificationUserIdProvider : IUserIdProvider
{
public string? GetUserId(HubConnectionContext connection) =>
connection.User?.FindFirst("UserId")?.Value;
}