using Application.Abstractions.Hub; using Microsoft.AspNetCore.SignalR; namespace Infrastructure.Hubs; internal sealed class FeedBroadcaster(IHubContext? hub = null) : IFeedBroadcaster { public async Task BroadcastNewPostAsync(IEnumerable followerMemberIDs, FeedPostToast toast, CancellationToken ct = default) { if (hub is null) { return; } var groups = followerMemberIDs.Select(id => $"member:{id}").ToList(); if (groups.Count == 0) { return; } await hub.Clients.Groups(groups).ReceiveFeedPost(new { toast.PostID, toast.AuthorSID, toast.AuthorName, toast.AuthorThumb, toast.Subject, toast.Thumbnail, toast.CreatedAt }); } }