Files
GmRelayBot/src/GmRelay.Shared/Features/Notifications/PlatformDirectNotificationSender.cs
T
Toutsu 2a707e4825
PR Checks / test-and-build (pull_request) Successful in 7m9s
feat(platform): route scheduler notifications through platform messenger
2026-05-21 12:30:35 +03:00

51 lines
1.6 KiB
C#

using GmRelay.Shared.Platform;
using Microsoft.Extensions.Logging;
namespace GmRelay.Shared.Features.Notifications;
public sealed class PlatformDirectNotificationSender(
IPlatformMessenger messenger,
ILogger<PlatformDirectNotificationSender> logger)
{
public async Task SendAsync(
PlatformDirectSessionNotificationKind kind,
IEnumerable<PlatformUser> recipients,
Guid sessionId,
string title,
DateTime scheduledAt,
string? joinLink,
string? actorDisplayName,
string? reason,
CancellationToken ct)
{
foreach (var recipient in recipients)
{
try
{
await messenger.SendDirectSessionNotificationAsync(
new PlatformDirectSessionNotification(
kind,
recipient,
sessionId,
title,
scheduledAt,
joinLink,
actorDisplayName,
reason),
ct);
}
catch (Exception ex)
{
logger.LogWarning(
ex,
"Failed to send {NotificationKind} notification for session {SessionId} to {Platform} user {ExternalUserId} ({DisplayName})",
kind,
sessionId,
recipient.Platform,
recipient.ExternalUserId,
recipient.DisplayName);
}
}
}
}