namespace QMax.Api.Infrastructure.Max; public sealed class MockMaxBridgeClient : IMaxBridgeClient { private readonly List _updates = [ new MaxChatUpdate( "mock-qmax", "QMAX smoke chat", null, DateTimeOffset.UtcNow, [ new MaxMessageUpdate( "mock-message-1", "max", "MAX", false, "Mock mode is active. Switch QMax:MaxMode to Worker and use qmax-pymax-worker for real MAX traffic.", DateTimeOffset.UtcNow) ]) ]; public Task GetStatusAsync(CancellationToken cancellationToken) { return Task.FromResult(new MaxBridgeStatus("Mock", true, "Authorized", "MockReady", null, "Mock", null, DateTimeOffset.UtcNow)); } public Task BeginPhoneLoginAsync(string phoneNumber, CancellationToken cancellationToken) { return GetStatusAsync(cancellationToken); } public Task SubmitLoginCodeAsync(string code, CancellationToken cancellationToken) { return GetStatusAsync(cancellationToken); } public Task GetSnapshotAsync(CancellationToken cancellationToken) { return Task.FromResult(new MaxBrowserSnapshot(null, "Mock", "Mock MAX bridge", "", DateTimeOffset.UtcNow)); } public Task> FetchUpdatesAsync(CancellationToken cancellationToken) { return Task.FromResult>(_updates); } public Task FetchChatHistoryAsync(string externalChatId, string? chatUrl, CancellationToken cancellationToken) { var update = _updates.FirstOrDefault(x => x.ExternalId == externalChatId); return Task.FromResult(update); } public Task FetchChatPresenceAsync(string externalChatId, string? chatUrl, CancellationToken cancellationToken) { return Task.FromResult(new MaxChatPresence(false, null, DateTimeOffset.UtcNow)); } public Task ResolveChatUrlAsync(string externalChatId, CancellationToken cancellationToken) { return Task.FromResult(new MaxChatUrlResult(true, MockChatUrl(externalChatId), null)); } public Task ClearChatHistoryAsync(string externalChatId, string? chatUrl, CancellationToken cancellationToken) { return Task.FromResult(new MaxActionResult(true, null)); } public Task DeleteChatAsync(string externalChatId, string? chatUrl, CancellationToken cancellationToken) { return Task.FromResult(new MaxActionResult( false, "Chat deletion is disabled because MAX does not remove chats from the web client.")); } public Task SendTextAsync(string externalChatId, string? chatUrl, string text, CancellationToken cancellationToken) { return Task.FromResult(new MaxSendResult(true, $"mock-out-{Guid.NewGuid():N}", null, MockChatUrl(externalChatId))); } public Task SendAttachmentAsync(string externalChatId, string? chatUrl, string path, string caption, CancellationToken cancellationToken) { return Task.FromResult(new MaxSendResult(true, $"mock-file-{Guid.NewGuid():N}", null, MockChatUrl(externalChatId))); } public Task EditMessageAsync(string externalChatId, string externalMessageId, string? currentText, string text, CancellationToken cancellationToken) { return Task.FromResult(new MaxActionResult(true, null)); } public Task DeleteMessageAsync(string externalChatId, string externalMessageId, string? currentText, CancellationToken cancellationToken) { return Task.FromResult(new MaxActionResult(true, null)); } public Task SetReactionAsync(string externalChatId, string externalMessageId, string? currentText, string emoji, CancellationToken cancellationToken) { return Task.FromResult(new MaxActionResult(true, null)); } public Task ClearReactionAsync(string externalChatId, string externalMessageId, string? currentText, string emoji, CancellationToken cancellationToken) { return Task.FromResult(new MaxActionResult(true, null)); } public Task DownloadMediaAsync(string remoteUrl, CancellationToken cancellationToken) { return Task.FromResult(null); } private static string MockChatUrl(string externalChatId) { return $"pymax://mock/{Uri.EscapeDataString(externalChatId)}"; } }