Authorize data sync on connected agent registration
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user