✨ Drive resource recycler, delete files in batch
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user