mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
42 lines
957 B
C#
42 lines
957 B
C#
using RadicadeServer.API.Notifications;
|
|
using RadicadeServer.RecNet.Enums.Messages;
|
|
using RadicadeServer.RecNet.Notifications;
|
|
|
|
namespace RadicadeServer.RecNet.Board
|
|
{
|
|
public static class CommunityBoardBroadcast
|
|
{
|
|
public const string UpdateNotificationId = "CommunityBoardUpdate";
|
|
|
|
public static IReadOnlyList<Notification> BuildFrames(CommunityBoard? board)
|
|
{
|
|
if (board == null)
|
|
return Array.Empty<Notification>();
|
|
|
|
return new List<Notification>
|
|
{
|
|
new Notification
|
|
{
|
|
Id = UpdateNotificationId,
|
|
Msg = board
|
|
},
|
|
new Notification
|
|
{
|
|
Id = NotificationType.CommunityBoardAnnouncementUpdate,
|
|
Msg = board.CurrentAnnouncement ?? new BoardAnnouncement
|
|
{
|
|
Message = string.Empty,
|
|
MoreInfoUrl = string.Empty
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
public static async Task PushAsync(CommunityBoard? board)
|
|
{
|
|
foreach (var frame in BuildFrames(board))
|
|
await Notify.SendGlobalNotify(frame);
|
|
}
|
|
}
|
|
}
|