Add SQL outbox for MAX sends

This commit is contained in:
sevenhill
2026-07-05 13:47:07 +03:00
parent 5d33320e3d
commit 6dd5c7c6fb
8 changed files with 462 additions and 123 deletions
+7
View File
@@ -95,7 +95,9 @@ builder.Services.AddScoped<ChatProjectionService>();
builder.Services.AddScoped<IPushNotificationService, FirebasePushNotificationService>();
builder.Services.AddSingleton<IAttachmentStorageService, AttachmentStorageService>();
builder.Services.AddSingleton<MaxBridgeSyncService>();
builder.Services.AddScoped<MaxOutboxService>();
builder.Services.AddHostedService<MaxSyncWorker>();
builder.Services.AddHostedService<MaxOutboxWorker>();
if (string.Equals(configuredOptions.MaxMode, "Mock", StringComparison.OrdinalIgnoreCase))
{
@@ -176,6 +178,11 @@ static async Task EnsureCompatibilitySchemaAsync(QMaxDbContext db)
ON Messages (ChatId, ExternalId);
""");
await db.Database.ExecuteSqlRawAsync("""
CREATE INDEX IF NOT EXISTS IX_Messages_DeliveryState_SentAt
ON Messages (DeliveryState, SentAt);
""");
await db.Database.ExecuteSqlRawAsync("""
CREATE TABLE IF NOT EXISTS MessageReactions (
Id TEXT NOT NULL CONSTRAINT PK_MessageReactions PRIMARY KEY,