Merge branch 'Feature/program-manager/signalR-notification' into Main

This commit is contained in:
2025-12-15 10:15:01 +03:30
3 changed files with 12 additions and 4 deletions

View File

@@ -199,7 +199,7 @@ public class AuthHelper : IAuthHelper
new("WorkshopSlug",slug),
new("WorkshopId", account.WorkshopId.ToString()),
new("WorkshopName",account.WorkshopName??""),
new("pm.userId", account.PmUserId?.ToString() ?? "0"),
new("pm.userId", account.PmUserId.ToString()),
};

View File

@@ -6,8 +6,16 @@ public class ProjectBoardHub:Hub
{
public override async Task OnConnectedAsync()
{
Console.WriteLine($"{Context.ConnectionId} connected");
await Clients.All.SendAsync("ReceiveGreeting","A new user has connected to the Project Board Hub!");
var user = Context.User?.FindFirst("pm.userId")?.Value;
if (user != null && user !="0")
{
await Groups.AddToGroupAsync(
Context.ConnectionId,
$"pm.user-{user}"
);
}
await base.OnConnectedAsync();
}
}

View File

@@ -24,7 +24,7 @@ public class SignalRBoardNotificationPublisher:IBoardNotificationPublisher
NewStatus = newStatus,
SectionId = sectionId
};
_hubContext.Clients.User(userId.ToString()).SendAsync("ReceiveProjectStatusChanged",payload);
_hubContext.Clients.Group($"pm.user-{userId}").SendAsync("ReceiveProjectStatusChanged",payload);
return Task.CompletedTask;
}
}