fix(channel): 修复 inApp 通知方式被 Normalize 误过滤

统一映射为 canonical code inApp,并修正站内信显示名匹配。
This commit is contained in:
zzh 2026-07-06 15:39:22 +08:00
parent 0c763f9707
commit 9359c9cb5b

View File

@ -8,22 +8,22 @@ public static class IssueNotifyMethodCodes
public const string Feishu = "feishu";
public const string Wechat = "wechat";
public static readonly HashSet<string> All =
[
public static readonly HashSet<string> All = new(StringComparer.OrdinalIgnoreCase)
{
InApp,
Email,
Sms,
Feishu,
Wechat
];
};
public static string GetDisplayName(string? code) => code?.Trim().ToLowerInvariant() switch
{
InApp => "站内信",
Email => "邮件",
Sms => "短信",
Feishu => "飞书",
Wechat => "微信",
"inapp" => "站内信",
"email" => "邮件",
"sms" => "短信",
"feishu" => "飞书",
"wechat" => "微信",
_ => code ?? string.Empty
};
@ -36,8 +36,9 @@ public static class IssueNotifyMethodCodes
var parts = raw
.Split([',', ';', ' '], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Select(x => x.ToLowerInvariant())
.Where(x => All.Contains(x))
.Select(ToCanonical)
.Where(x => x != null)
.Cast<string>()
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
@ -54,4 +55,22 @@ public static class IssueNotifyMethodCodes
return normalized.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList();
}
private static string? ToCanonical(string raw)
{
if (string.IsNullOrWhiteSpace(raw))
{
return null;
}
return raw.Trim().ToLowerInvariant() switch
{
"inapp" => InApp,
"email" => Email,
"sms" => Sms,
"feishu" => Feishu,
"wechat" => Wechat,
_ => null
};
}
}