feat(cqrs): update controllers, add AutoMapper profiles, SignalR notifications, Hangfire config

- 13 controllers migrated from service DI to IMediator dispatch
- 11 AutoMapper mapping profiles (Sites, Cameras, Auth, Users, Agents, Events, Assignments, Settings, Groups, Persons, Discovery)
- SignalR notifications bridged via MediatR INotificationHandler
- Hangfire config moved from Program.cs to Infrastructure/BackgroundJobs
- 0 build errors, 0 warnings
This commit is contained in:
Arnaud Dartois committed 2026-07-22 19:54:55 +00:00
1 parent c1b3b3d3b4
commit 1d1ac8387e
33 files changed
+611 -195

No files matched your search

+3 -31
View File
@@ -6,13 +6,12 @@ using Heimdall.Application;
using Heimdall.Application.Services;
using Heimdall.Infrastructure;
using Heimdall.Infrastructure.Data;
using Heimdall.Infrastructure.Jobs;
using Heimdall.Infrastructure.BackgroundJobs;
using Heimdall.Infrastructure.Security;
using Heimdall.Web.Components;
using Heimdall.Api.Hubs;
using Heimdall.Web.Services;
using Hangfire;
using Hangfire.PostgreSql;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer;
@@ -190,25 +189,7 @@ var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")
if (!isTesting && !string.IsNullOrEmpty(connectionString))
{
#pragma warning disable CS0618
builder.Services.AddHangfire(config =>
{
config.UsePostgreSqlStorage(connectionString, new PostgreSqlStorageOptions
{
SchemaName = "hangfire"
});
});
#pragma warning restore CS0618
builder.Services.AddHangfireServer(options =>
{
options.WorkerCount = 2;
options.Queues = ["default", "heartbeat"];
});
// ── Jobs ──────────────────────────────────────────────────────────
builder.Services.AddScoped<HeartbeatMonitorJob>();
builder.Services.AddScoped<AgentFailoverJob>();
builder.Services.AddBackgroundJobs(builder.Configuration);
}
// ── HTTP client for Heimdall API (with auto-refresh handler) ──────
@@ -411,16 +392,7 @@ if (!isTesting && !string.IsNullOrEmpty(connectionString))
using (var scope = app.Services.CreateScope())
{
var manager = scope.ServiceProvider.GetRequiredService<IRecurringJobManager>();
manager.AddOrUpdate<HeartbeatMonitorJob>(
"heartbeat-monitor",
job => job.ExecuteAsync(CancellationToken.None),
"*/1 * * * *"); // Every minute
manager.AddOrUpdate<AgentFailoverJob>(
"agent-failover",
job => job.ExecuteAsync(CancellationToken.None),
"*/1 * * * *"); // Every minute — checks for stale heartbeats
Heimdall.Infrastructure.BackgroundJobs.JobSetup.ConfigureRecurringJobs(manager);
}
}