🐛 Fixes DI and lifetimes
This commit is contained in:
@@ -9,8 +9,7 @@ namespace DysonNetwork.Drive.Startup;
|
||||
public class BroadcastEventHandler(
|
||||
INatsConnection nats,
|
||||
ILogger<BroadcastEventHandler> logger,
|
||||
FileService fs,
|
||||
AppDatabase db
|
||||
IServiceProvider serviceProvider
|
||||
) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
@@ -23,7 +22,11 @@ public class BroadcastEventHandler(
|
||||
if (evt == null) continue;
|
||||
|
||||
logger.LogInformation("Account deleted: {AccountId}", evt.AccountId);
|
||||
|
||||
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var fs = scope.ServiceProvider.GetRequiredService<FileService>();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
|
||||
|
||||
await using var transaction = await db.Database.BeginTransactionAsync(cancellationToken: stoppingToken);
|
||||
try
|
||||
{
|
||||
|
@@ -4,6 +4,7 @@ using DysonNetwork.Pass.Startup;
|
||||
using DysonNetwork.Shared.Http;
|
||||
using DysonNetwork.Shared.PageData;
|
||||
using DysonNetwork.Shared.Registry;
|
||||
using DysonNetwork.Shared.Stream;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -16,6 +17,7 @@ builder.Services.AddAppMetrics();
|
||||
|
||||
// Add application services
|
||||
builder.Services.AddRegistryService(builder.Configuration);
|
||||
builder.Services.AddStreamConnection(builder.Configuration);
|
||||
builder.Services.AddAppServices(builder.Configuration);
|
||||
builder.Services.AddAppRateLimiting();
|
||||
builder.Services.AddAppAuthentication();
|
||||
|
@@ -8,7 +8,7 @@ namespace DysonNetwork.Sphere.Startup;
|
||||
public class BroadcastEventHandler(
|
||||
INatsConnection nats,
|
||||
ILogger<BroadcastEventHandler> logger,
|
||||
AppDatabase db
|
||||
IServiceProvider serviceProvider
|
||||
) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
@@ -22,7 +22,9 @@ public class BroadcastEventHandler(
|
||||
|
||||
logger.LogInformation("Account deleted: {AccountId}", evt.AccountId);
|
||||
|
||||
// TODO: Add empty realm, chat recycler in the db recycle
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
|
||||
|
||||
await db.ChatMembers
|
||||
.Where(m => m.AccountId == evt.AccountId)
|
||||
.ExecuteDeleteAsync(cancellationToken: stoppingToken);
|
||||
|
Reference in New Issue
Block a user