Refactored event service injection
This commit is contained in:
@@ -18,7 +18,7 @@ public sealed class ProcessEmailEvent : IEvent
|
||||
}
|
||||
|
||||
public sealed class ProcessEmailEventHandler(IDbContextFactory<ApplicationDbContext> contextFactory,
|
||||
IFeatureManager featureManager, EmailService emailService, ISkorubaUserService skorubaUserService) : INotificationHandler<ProcessEmailEvent>
|
||||
IServiceProvider provider, IFeatureManager featureManager) : INotificationHandler<ProcessEmailEvent>
|
||||
{
|
||||
const int maxBatch = 100;
|
||||
|
||||
@@ -26,6 +26,10 @@ public sealed class ProcessEmailEventHandler(IDbContextFactory<ApplicationDbCont
|
||||
{
|
||||
if (!await featureManager.IsEnabledAsync(FeatureEmailProcessor)) return;
|
||||
|
||||
var scope = provider.CreateScope().ServiceProvider;
|
||||
var emailService = scope.GetRequiredService<EmailService>();
|
||||
var skorubaUserService = scope.GetRequiredService<ISkorubaUserService>();
|
||||
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
var outgoing = await context.Notifications.AsNoTracking()
|
||||
|
||||
Reference in New Issue
Block a user