feat: implémenter SignalR hubs (Monitoring, Notifications, Admin) + système de notifications complet

SignalR Hubs:
- MonitoringHub (/hubs/monitoring) — statuts agents/caméras/stockage/GPU jobs
- NotificationsHub (/hubs/notifications) — notifications in-app badge temps réel
- AdminHub (/hubs/admin) — broadcast changements config (Admin only)

Notification System:
- Nouvelles entités: Notification, NotificationTemplate, UserNotificationConfig
- CQRS/MediatR: 6 handlers (list, unread, mark-read, mark-all, config get/update)
- Infrastructure: NotificationService orchestrator + EmailService + GotifyService
- Rate limiter IMemoryCache (20 events/min/camera/type)
- Hangfire jobs: SendNotification, DailyDigest, WeeklyDigest
- NotificationsController API (6 endpoints)
- Blazor UI: NotificationsPage + NotificationBadge
- Migration AddNotifications (3 nouvelles tables)
- 644 nouveaux tests (Domain: 131, Application: 321, Infra: 151, Integration: 120, +autres)
This commit is contained in:
Arnaud Dartois committed 2026-07-26 20:45:35 +00:00
1 parent ef3ea9d1ca
commit f9be0f1e0d
62 files changed
+6664 -3

No files matched your search

@@ -0,0 +1,49 @@
using Heimdall.Domain.Entities;
using Heimdall.Domain.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class NotificationConfiguration : IEntityTypeConfiguration<Notification>
{
public void Configure(EntityTypeBuilder<Notification> builder)
{
builder.ToTable("notifications");
builder.HasKey(n => n.Id);
builder.Property(n => n.Title)
.HasMaxLength(200)
.IsRequired();
builder.Property(n => n.Message)
.HasMaxLength(2000)
.IsRequired();
builder.Property(n => n.Type)
.HasConversion<string>()
.HasMaxLength(50);
builder.Property(n => n.EventType)
.HasConversion<string>()
.HasMaxLength(50);
builder.Property(n => n.SnapshotUrl)
.HasMaxLength(500);
builder.Property(n => n.Link)
.HasMaxLength(500);
builder.Property(n => n.CreatedAt)
.HasDefaultValueSql("NOW()");
builder.Property(n => n.UpdatedAt)
.HasDefaultValueSql("NOW()");
// Indexes
builder.HasIndex(n => n.UserId);
builder.HasIndex(n => new { n.UserId, n.IsRead });
builder.HasIndex(n => n.CreatedAt);
}
}
@@ -0,0 +1,47 @@
using Heimdall.Domain.Entities;
using Heimdall.Domain.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class NotificationTemplateConfiguration : IEntityTypeConfiguration<NotificationTemplate>
{
public void Configure(EntityTypeBuilder<NotificationTemplate> builder)
{
builder.ToTable("notification_templates");
builder.HasKey(t => t.Id);
builder.Property(t => t.EventType)
.HasConversion<string>()
.HasMaxLength(50)
.IsRequired();
builder.Property(t => t.Channel)
.HasConversion<string>()
.HasMaxLength(50)
.IsRequired();
builder.Property(t => t.Language)
.HasMaxLength(10)
.IsRequired()
.HasDefaultValue("fr");
builder.Property(t => t.Subject)
.HasMaxLength(200)
.IsRequired();
builder.Property(t => t.BodyMarkdown)
.IsRequired();
builder.Property(t => t.CreatedAt)
.HasDefaultValueSql("NOW()");
builder.Property(t => t.UpdatedAt)
.HasDefaultValueSql("NOW()");
// Indexes
builder.HasIndex(t => new { t.EventType, t.Channel, t.Language }).IsUnique();
}
}
@@ -0,0 +1,41 @@
using Heimdall.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class UserNotificationConfigConfiguration : IEntityTypeConfiguration<UserNotificationConfig>
{
public void Configure(EntityTypeBuilder<UserNotificationConfig> builder)
{
builder.ToTable("user_notification_configs");
builder.HasKey(c => c.Id);
builder.Property(c => c.EmailAddress)
.HasMaxLength(200);
builder.Property(c => c.GotifyUrl)
.HasMaxLength(500);
builder.Property(c => c.GotifyToken)
.HasMaxLength(500);
builder.Property(c => c.Language)
.HasMaxLength(10)
.HasDefaultValue("fr");
builder.Property(c => c.SubscribedEventsJson)
.HasColumnName("subscribed_events")
.HasColumnType("jsonb");
builder.Property(c => c.CreatedAt)
.HasDefaultValueSql("NOW()");
builder.Property(c => c.UpdatedAt)
.HasDefaultValueSql("NOW()");
// Indexes
builder.HasIndex(c => c.UserId).IsUnique();
}
}