Drive resource recycler, delete files in batch

This commit is contained in:
2025-08-20 00:11:52 +08:00
parent 56c40ee001
commit 9e8363c004
7 changed files with 124 additions and 17 deletions

View File

@@ -21,6 +21,15 @@ public class BroadcastEventHandler(
if (evt == null) continue;
logger.LogInformation("Account deleted: {AccountId}", evt.AccountId);
// TODO: Add empty realm, chat recycler in the db recycle
await db.ChatMembers
.Where(m => m.AccountId == evt.AccountId)
.ExecuteDeleteAsync(cancellationToken: stoppingToken);
await db.RealmMembers
.Where(m => m.AccountId == evt.AccountId)
.ExecuteDeleteAsync(cancellationToken: stoppingToken);
await using var transaction = await db.Database.BeginTransactionAsync(cancellationToken: stoppingToken);
try
@@ -33,6 +42,11 @@ public class BroadcastEventHandler(
await db.Posts
.Where(p => p.PublisherId == publisher.Id)
.ExecuteDeleteAsync(cancellationToken: stoppingToken);
var publisherIds = publishers.Select(p => p.Id).ToList();
await db.Publishers
.Where(p => publisherIds.Contains(p.Id))
.ExecuteDeleteAsync(cancellationToken: stoppingToken);
await transaction.CommitAsync(cancellationToken: stoppingToken);
}