fix(channel): 修复 inApp 通知方式被 Normalize 误过滤
统一映射为 canonical code inApp,并修正站内信显示名匹配。
This commit is contained in:
parent
0c763f9707
commit
9359c9cb5b
@ -8,22 +8,22 @@ public static class IssueNotifyMethodCodes
|
|||||||
public const string Feishu = "feishu";
|
public const string Feishu = "feishu";
|
||||||
public const string Wechat = "wechat";
|
public const string Wechat = "wechat";
|
||||||
|
|
||||||
public static readonly HashSet<string> All =
|
public static readonly HashSet<string> All = new(StringComparer.OrdinalIgnoreCase)
|
||||||
[
|
{
|
||||||
InApp,
|
InApp,
|
||||||
Email,
|
Email,
|
||||||
Sms,
|
Sms,
|
||||||
Feishu,
|
Feishu,
|
||||||
Wechat
|
Wechat
|
||||||
];
|
};
|
||||||
|
|
||||||
public static string GetDisplayName(string? code) => code?.Trim().ToLowerInvariant() switch
|
public static string GetDisplayName(string? code) => code?.Trim().ToLowerInvariant() switch
|
||||||
{
|
{
|
||||||
InApp => "站内信",
|
"inapp" => "站内信",
|
||||||
Email => "邮件",
|
"email" => "邮件",
|
||||||
Sms => "短信",
|
"sms" => "短信",
|
||||||
Feishu => "飞书",
|
"feishu" => "飞书",
|
||||||
Wechat => "微信",
|
"wechat" => "微信",
|
||||||
_ => code ?? string.Empty
|
_ => code ?? string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,8 +36,9 @@ public static class IssueNotifyMethodCodes
|
|||||||
|
|
||||||
var parts = raw
|
var parts = raw
|
||||||
.Split([',', ';', ' '], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
.Split([',', ';', ' '], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||||
.Select(x => x.ToLowerInvariant())
|
.Select(ToCanonical)
|
||||||
.Where(x => All.Contains(x))
|
.Where(x => x != null)
|
||||||
|
.Cast<string>()
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
@ -54,4 +55,22 @@ public static class IssueNotifyMethodCodes
|
|||||||
|
|
||||||
return normalized.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList();
|
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
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user