fix: register verified bound accounts remotely

This commit is contained in:
2026-09-20 23:42:29 +08:00
parent 15b0477b44
commit f8290a65bc
@@ -142,7 +142,7 @@ public sealed class RemoteAgentHostedService(
}
var currentSnapshot = await ReadSnapshotAsync(remote, cancellationToken);
if (!string.Equals(remote.ActiveAccountId, task.AccountId, StringComparison.Ordinal) || !currentSnapshot.ActiveAccountVerified)
if (!string.Equals(currentSnapshot.ActiveAccountId, task.AccountId, StringComparison.Ordinal) || !currentSnapshot.ActiveAccountVerified)
{
var result = new RemoteTaskResult(task.TaskId, task.AccountId, task.LeaseGeneration,
RemoteTaskStatus.Failed, "AccountContextUnconfirmed", "The active account binding could not be confirmed.", false, null, Guid.NewGuid().ToString("N"));
@@ -453,16 +453,16 @@ public sealed class RemoteAgentHostedService(
new(remote.NodeId!, typeof(RemoteAgentHostedService).Assembly.GetName().Version?.ToString() ?? "dev",
RemoteProtocol.Version, ["heartbeat", "poll-tasks", "send-text", "read-sessions", "read-contacts", "read-messages", "report-message"], reporting.ConfigVersion,
snapshot.Accounts
.Where(identity => reporting.Accounts.Any(account => account.Enabled && string.Equals(account.AccountId, identity.AccountId, StringComparison.Ordinal)))
.Where(identity => identity.Verified)
.Select(identity =>
{
var account = reporting.FindAccount(identity.AccountId)!;
var account = reporting.FindAccount(identity.AccountId);
return new RemoteAccountSummary(
identity.AccountId,
string.Equals(identity.AccountId, remote.ActiveAccountId, StringComparison.Ordinal),
string.Equals(identity.AccountId, snapshot.ActiveAccountId, StringComparison.Ordinal),
identity.Verified,
account.AllowedChats.Count(chat => chat.Type == ReportingChatType.Group && chat.Enabled && chat.IdentityVerified),
account.AllowedChats.Count(chat => chat.Type == ReportingChatType.Private && chat.Enabled && chat.IdentityVerified));
account?.AllowedChats.Count(chat => chat.Type == ReportingChatType.Group && chat.Enabled && chat.IdentityVerified) ?? 0,
account?.AllowedChats.Count(chat => chat.Type == ReportingChatType.Private && chat.Enabled && chat.IdentityVerified) ?? 0);
}).ToArray());
private static RemoteHeartbeat CreateHeartbeat(RemoteAgentOptions remote, ReportingConfig reporting, BackendSnapshot snapshot, string? errorCode) =>