feat: add account-scoped data synchronization

This commit is contained in:
2026-09-22 09:58:58 +08:00
parent ab9ff389f2
commit 72e040546a
37 changed files with 4252 additions and 159 deletions
@@ -4,11 +4,12 @@ using WxAgent.Windows;
namespace WxAgent.Host;
public sealed class WindowsAgentBackend(AccountBindingStore bindings, ServiceOptions options) : IAgentBackend, IAgentEventSource
public sealed class WindowsAgentBackend(AccountBindingStore bindings, ServiceOptions options) : IAgentBackend, IAgentEventSource, IRemoteDataCollector
{
private readonly bool validationOperationsEnabled = options.EnableValidationOperations;
private readonly bool listenerEventsEnabled = options.EnableListenerEvents;
private readonly SemaphoreSlim bindingGate = new(1, 1);
private readonly DatabaseMessageSyncCollector databaseSyncCollector = new(null, options.DataSyncBatchLimit, options.DataSyncOverlapRows);
public IReadOnlyList<AgentCapability> Capabilities =>
[
@@ -439,6 +440,13 @@ public sealed class WindowsAgentBackend(AccountBindingStore bindings, ServiceOpt
return new Page<GroupMemberInfo>(items, limit, offset, page.HasMore, page.NextOffset);
}
public Task<RemoteDataCollection> CollectAsync(
string accountId,
IReadOnlyList<RemoteReportingScope> scopes,
RemoteDataSyncCheckpoint checkpoint,
CancellationToken cancellationToken) =>
databaseSyncCollector.CollectAsync(accountId, scopes, checkpoint, cancellationToken);
public async Task<IReadOnlyList<DatabaseMessageInfo>> DatabaseMessagesAsync(string accountId, string chatId, int limit, long? localId, CancellationToken cancellationToken)
{
var account = await DatabaseKeyStore.LoadAsync(null, cancellationToken);