From 47f3c020118d20bdb7a4d1f6cb8583fc7ca7c887 Mon Sep 17 00:00:00 2001 From: Rogee Date: Tue, 22 Sep 2026 16:56:05 +0800 Subject: [PATCH] Authorize configured accounts during offline startup --- .../WxAgent.Service/RemoteAgentHostedService.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/node-agent/WxAgent.Service/RemoteAgentHostedService.cs b/node-agent/WxAgent.Service/RemoteAgentHostedService.cs index f475ce0..f995bae 100644 --- a/node-agent/WxAgent.Service/RemoteAgentHostedService.cs +++ b/node-agent/WxAgent.Service/RemoteAgentHostedService.cs @@ -52,7 +52,7 @@ public sealed class RemoteAgentHostedService( string? registeredActiveAccountId = null; bool? registeredActiveAccountVerified = null; long registeredReportingConfigVersion = -1; - ReportingConfig? activeReporting = null; + ReportingConfig? activeReporting = ConnectionAuthorizedReporting(options.Reporting, null); var retry = RetryDelay; while (!stoppingToken.IsCancellationRequested) { @@ -738,13 +738,16 @@ public sealed class RemoteAgentHostedService( } } - private static ReportingConfig ConnectionAuthorizedReporting(ReportingConfig configured, BackendSnapshot snapshot) + private static ReportingConfig ConnectionAuthorizedReporting(ReportingConfig configured, BackendSnapshot? snapshot) { - var accounts = snapshot.Accounts - .Where(identity => identity.Verified) - .Select(identity => new AccountReportingConfig + var accountIds = snapshot is not null + ? snapshot.Accounts.Where(identity => identity.Verified).Select(identity => identity.AccountId) + : configured.Accounts.Where(account => account.Enabled).Select(account => account.AccountId); + var accounts = accountIds + .Distinct(StringComparer.Ordinal) + .Select(accountId => new AccountReportingConfig { - AccountId = identity.AccountId, + AccountId = accountId, Enabled = true, AllowedChats = [