|
|
@@ -11,7 +11,6 @@ namespace molilian.core
|
|
|
public const string ExceptionRedisPrefix = $"{RedisPrefix}:exception";
|
|
|
private const string ExceptionAggregateType = "all";
|
|
|
private const string ForwardUrlTemplate = "https://tracker.z-long.cn/ad/tracker/special/liutiyun/{0}";
|
|
|
- private static readonly string[] SupportedChannels = new[] { "xhs", "ks" };
|
|
|
private static readonly HttpClient HttpClient = new()
|
|
|
{
|
|
|
Timeout = TimeSpan.FromSeconds(10)
|
|
|
@@ -101,7 +100,7 @@ namespace molilian.core
|
|
|
list.Add(item);
|
|
|
}
|
|
|
|
|
|
- if (!string.Equals(channel, "xhs", StringComparison.OrdinalIgnoreCase)) continue;
|
|
|
+ if (!ZlongForwardChannels.UsesLegacyKeys(channel)) continue;
|
|
|
|
|
|
string[] legacyKeys = await TkLogCore.GetTotalKeysAsync(GetLegacyIndexKey(normalizedBucketType)) ?? Array.Empty<string>();
|
|
|
foreach (var key in legacyKeys)
|
|
|
@@ -194,7 +193,7 @@ namespace molilian.core
|
|
|
|
|
|
tasks.Add(TkLogCore.GetTotalAsync(key));
|
|
|
|
|
|
- if (!string.Equals(channel, "xhs", StringComparison.OrdinalIgnoreCase)) continue;
|
|
|
+ if (!ZlongForwardChannels.UsesLegacyKeys(channel)) continue;
|
|
|
|
|
|
string legacyKey = isException
|
|
|
? GetLegacyExceptionCountKey(ExceptionAggregateType, bucketType, bucketValue)
|
|
|
@@ -251,38 +250,17 @@ namespace molilian.core
|
|
|
|
|
|
private static string[] NormalizeChannels(string channels)
|
|
|
{
|
|
|
- if (string.IsNullOrWhiteSpace(channels)) return SupportedChannels;
|
|
|
-
|
|
|
- var list = new List<string>();
|
|
|
- foreach (var item in channels.Split(',', StringSplitOptions.RemoveEmptyEntries))
|
|
|
- {
|
|
|
- string normalized = item.Trim().ToLowerInvariant();
|
|
|
- if (string.Equals(normalized, "all", StringComparison.OrdinalIgnoreCase))
|
|
|
- {
|
|
|
- return SupportedChannels;
|
|
|
- }
|
|
|
-
|
|
|
- normalized = NormalizeChannel(normalized);
|
|
|
- if (string.IsNullOrEmpty(normalized) || list.Contains(normalized)) continue;
|
|
|
-
|
|
|
- list.Add(normalized);
|
|
|
- }
|
|
|
-
|
|
|
- return list.Count > 0 ? list.ToArray() : SupportedChannels;
|
|
|
+ return ZlongForwardChannels.NormalizeChannels(channels);
|
|
|
}
|
|
|
|
|
|
private static string NormalizeChannel(string channel)
|
|
|
{
|
|
|
- if (string.IsNullOrWhiteSpace(channel)) return string.Empty;
|
|
|
-
|
|
|
- string normalized = channel.Trim().ToLowerInvariant();
|
|
|
- return SupportedChannels.Contains(normalized) ? normalized : string.Empty;
|
|
|
+ return ZlongForwardChannels.NormalizeChannel(channel);
|
|
|
}
|
|
|
|
|
|
private static int GetChannelSortOrder(string channel)
|
|
|
{
|
|
|
- int index = Array.IndexOf(SupportedChannels, channel);
|
|
|
- return index >= 0 ? index : SupportedChannels.Length;
|
|
|
+ return ZlongForwardChannels.GetSortOrder(channel);
|
|
|
}
|
|
|
|
|
|
private static string GetIndexKey(string channel, string bucketType)
|
|
|
@@ -375,7 +353,7 @@ namespace molilian.core
|
|
|
var parts = key.Split(':', StringSplitOptions.RemoveEmptyEntries);
|
|
|
if (parts.Length < 4) return false;
|
|
|
|
|
|
- string channel = "xhs";
|
|
|
+ string channel = ZlongForwardChannels.LegacyChannel;
|
|
|
string bucketType = parts[^2];
|
|
|
string bucketValue = parts[^1];
|
|
|
if (parts.Length >= 5)
|