Files
GmRelayBot/src/GmRelay.Shared/Domain/SessionNotificationMode.cs
T
Toutsu a8f2b10956
Deploy Telegram Bot / build-and-push (push) Successful in 3m36s
Deploy Telegram Bot / deploy (push) Successful in 11s
feat: send personal player notifications
2026-04-27 10:11:11 +03:00

34 lines
1.3 KiB
C#

namespace GmRelay.Shared.Domain;
public enum SessionNotificationMode
{
GroupAndDirect,
GroupOnly
}
public static class SessionNotificationModeExtensions
{
public const string GroupAndDirectValue = nameof(SessionNotificationMode.GroupAndDirect);
public const string GroupOnlyValue = nameof(SessionNotificationMode.GroupOnly);
public static bool ShouldSendDirectMessages(this SessionNotificationMode mode) =>
mode == SessionNotificationMode.GroupAndDirect;
public static string ToDatabaseValue(this SessionNotificationMode mode) =>
mode switch
{
SessionNotificationMode.GroupAndDirect => GroupAndDirectValue,
SessionNotificationMode.GroupOnly => GroupOnlyValue,
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, "Unknown notification mode.")
};
public static SessionNotificationMode FromDatabaseValue(string? value) =>
value switch
{
null or "" => SessionNotificationMode.GroupAndDirect,
GroupAndDirectValue => SessionNotificationMode.GroupAndDirect,
GroupOnlyValue => SessionNotificationMode.GroupOnly,
_ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown notification mode.")
};
}