Authorize data sync on connected agent registration

This commit is contained in:
2026-09-22 16:47:52 +08:00
parent 49c07cca30
commit e26535781d
17 changed files with 194 additions and 110 deletions
@@ -56,9 +56,15 @@ public static class WechatSessionDbReader
.Where(scope => !string.IsNullOrWhiteSpace(scope.ChatId))
.DistinctBy(scope => $"{scope.ChatType}:{scope.ChatId}")
.ToArray();
var allChats = authorized.Any(scope => scope.ChatId == "*");
var allowed = authorized
.Where(scope => scope.ChatId != "*")
.Select(scope => (scope.ChatId, scope.ChatType))
.ToHashSet();
var allowedTypes = authorized
.Where(scope => scope.ChatId == "*")
.Select(scope => scope.ChatType)
.ToHashSet();
var directoryRows = rows
.Select(row =>
{
@@ -75,7 +81,9 @@ public static class WechatSessionDbReader
LastActivityAt = timestamp > 0 ? DateTimeOffset.FromUnixTimeSeconds(timestamp) : (DateTimeOffset?)null
};
})
.Where(row => allowed.Contains((row.ChatId, row.ChatType)))
.Where(row => allChats
? allowedTypes.Contains(row.ChatType)
: allowed.Contains((row.ChatId, row.ChatType)))
.ToArray();
IReadOnlyDictionary<string, string> names;