Queue chat bulk actions through SQL outbox
This commit is contained in:
@@ -14,6 +14,13 @@ public sealed class Chat
|
||||
public bool IsPinned { get; set; }
|
||||
public bool IsMuted { get; set; }
|
||||
public bool IsArchived { get; set; }
|
||||
public DateTimeOffset? DeletedAt { get; set; }
|
||||
public DateTimeOffset? HistoryClearedAt { get; set; }
|
||||
public ChatPendingMaxAction? PendingMaxAction { get; set; }
|
||||
public DateTimeOffset? PendingMaxActionRequestedAt { get; set; }
|
||||
public DateTimeOffset? PendingMaxActionLastAttemptAt { get; set; }
|
||||
public int PendingMaxActionAttempts { get; set; }
|
||||
public string? PendingMaxActionError { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
|
||||
@@ -8,6 +8,12 @@ public enum ChatKind
|
||||
MaxDialog = 3
|
||||
}
|
||||
|
||||
public enum ChatPendingMaxAction
|
||||
{
|
||||
ClearHistory = 0,
|
||||
DeleteChat = 1
|
||||
}
|
||||
|
||||
public enum MessageDirection
|
||||
{
|
||||
Incoming = 0,
|
||||
|
||||
@@ -19,6 +19,8 @@ public sealed class QMaxDbContext(DbContextOptions<QMaxDbContext> options) : DbC
|
||||
modelBuilder.Entity<User>().HasIndex(x => x.PhoneNumber);
|
||||
modelBuilder.Entity<UserSession>().HasIndex(x => x.RefreshTokenHash).IsUnique();
|
||||
modelBuilder.Entity<Chat>().HasIndex(x => x.ExternalId).IsUnique();
|
||||
modelBuilder.Entity<Chat>().HasIndex(x => x.DeletedAt);
|
||||
modelBuilder.Entity<Chat>().HasIndex(x => new { x.PendingMaxAction, x.PendingMaxActionRequestedAt });
|
||||
modelBuilder.Entity<Message>().HasIndex(x => new { x.ChatId, x.SentAt });
|
||||
modelBuilder.Entity<Message>().HasIndex(x => x.ExternalId);
|
||||
modelBuilder.Entity<MessageAttachment>().HasIndex(x => x.StorageFileName).IsUnique();
|
||||
@@ -30,6 +32,10 @@ public sealed class QMaxDbContext(DbContextOptions<QMaxDbContext> options) : DbC
|
||||
.Property(x => x.Kind)
|
||||
.HasConversion<string>();
|
||||
|
||||
modelBuilder.Entity<Chat>()
|
||||
.Property(x => x.PendingMaxAction)
|
||||
.HasConversion<string>();
|
||||
|
||||
modelBuilder.Entity<Message>()
|
||||
.Property(x => x.Direction)
|
||||
.HasConversion<string>();
|
||||
|
||||
Reference in New Issue
Block a user