fix(bot): skip join-link reminders without links
PR Checks / test-and-build (pull_request) Failing after 20m55s
PR Checks / test-and-build (pull_request) Failing after 20m55s
Prevent offline sessions with empty join links from entering the 5-minute join-link notification flow, omit blank link lines from direct reminders, and add offline persistence/reminder regression coverage.
This commit is contained in:
@@ -405,19 +405,8 @@ public sealed class TelegramPlatformMessenger(
|
||||
|
||||
Ответьте кнопкой в групповом сообщении расписания.
|
||||
""",
|
||||
PlatformDirectSessionNotificationKind.OneHourReminder => $"""
|
||||
⏰ <b>Игра начнётся примерно через 1 час</b>
|
||||
|
||||
📌 <b>{System.Net.WebUtility.HtmlEncode(notification.Title)}</b>
|
||||
📅 {notification.ScheduledAt.FormatMoscow()} (МСК)
|
||||
🔗 {System.Net.WebUtility.HtmlEncode(notification.JoinLink ?? string.Empty)}
|
||||
""",
|
||||
PlatformDirectSessionNotificationKind.JoinLink => $"""
|
||||
🎮 <b>Игра начинается через 5 минут</b>
|
||||
|
||||
📌 <b>{System.Net.WebUtility.HtmlEncode(notification.Title)}</b>
|
||||
🔗 {System.Net.WebUtility.HtmlEncode(notification.JoinLink ?? string.Empty)}
|
||||
""",
|
||||
PlatformDirectSessionNotificationKind.OneHourReminder => BuildOneHourReminderDirectText(notification),
|
||||
PlatformDirectSessionNotificationKind.JoinLink => BuildJoinLinkDirectText(notification),
|
||||
PlatformDirectSessionNotificationKind.RescheduleApproved => $"""
|
||||
✅ <b>Сессия перенесена по итогам голосования</b>
|
||||
|
||||
@@ -434,6 +423,39 @@ public sealed class TelegramPlatformMessenger(
|
||||
_ => BuildFallbackDirectText(notification)
|
||||
};
|
||||
|
||||
private static string BuildOneHourReminderDirectText(PlatformDirectSessionNotification notification)
|
||||
{
|
||||
var lines = new List<string>
|
||||
{
|
||||
"⏰ <b>Игра начнётся примерно через 1 час</b>",
|
||||
string.Empty,
|
||||
$"📌 <b>{System.Net.WebUtility.HtmlEncode(notification.Title)}</b>",
|
||||
$"📅 {notification.ScheduledAt.FormatMoscow()} (МСК)"
|
||||
};
|
||||
AppendJoinLinkLine(lines, notification.JoinLink);
|
||||
return string.Join("\n", lines);
|
||||
}
|
||||
|
||||
private static string BuildJoinLinkDirectText(PlatformDirectSessionNotification notification)
|
||||
{
|
||||
var lines = new List<string>
|
||||
{
|
||||
"🎮 <b>Игра начинается через 5 минут</b>",
|
||||
string.Empty,
|
||||
$"📌 <b>{System.Net.WebUtility.HtmlEncode(notification.Title)}</b>"
|
||||
};
|
||||
AppendJoinLinkLine(lines, notification.JoinLink);
|
||||
return string.Join("\n", lines);
|
||||
}
|
||||
|
||||
private static void AppendJoinLinkLine(List<string> lines, string? joinLink)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(joinLink))
|
||||
{
|
||||
lines.Add($"🔗 {System.Net.WebUtility.HtmlEncode(joinLink)}");
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildFallbackDirectText(PlatformDirectSessionNotification notification) =>
|
||||
$"<b>{System.Net.WebUtility.HtmlEncode(notification.Title)}</b>\n{notification.ScheduledAt.FormatMoscow()} (МСК)";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user