Contactbeheer: berichten, schakelaar en tweelaagse poort voor het formulier

Beheerroutes zonder /admin-segment op contact-messages (lijst met spam apart en ongelezen-teller zonder spam, detail, status, verwijderen, opnieuw versturen met eigen limiet) en contact-settings voor de CMS-schakelaar, allemaal AdminOnly. Het formulier is alleen open als de hostvlag EN de CMS-schakelaar (standaard uit) aan staan; de hostvlag wordt eerst gecontroleerd zodat de database niet wordt aangeraakt. Bij uitgeschakelde host antwoorden de beheerroutes 404. OpenAPI-document bijgewerkt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 13:07:28 +01:00
co-authored by Claude Sonnet 5.5
parent f8d45eef54
commit e53b318c31
23 changed files with 2704 additions and 10 deletions
@@ -7,6 +7,7 @@ public class ContactDbContext(DbContextOptions<ContactDbContext> options) : DbCo
{
public DbSet<ContactMessage> ContactMessages => Set<ContactMessage>();
public DbSet<IdempotencyRecord> IdempotencyRecords => Set<IdempotencyRecord>();
public DbSet<ContactSettings> ContactSettings => Set<ContactSettings>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -31,6 +32,16 @@ public class ContactDbContext(DbContextOptions<ContactDbContext> options) : DbCo
entity.HasIndex(e => e.RetentionUntil);
});
modelBuilder.Entity<ContactSettings>(entity =>
{
entity.ToTable("ContactSettings");
entity.HasKey(e => e.Id);
entity.Property(e => e.Id).ValueGeneratedNever();
entity.Property(e => e.Enabled).IsRequired();
entity.Property(e => e.UpdatedAt).IsRequired();
entity.Property(e => e.UpdatedByUserId).IsRequired();
});
modelBuilder.Entity<IdempotencyRecord>(entity =>
{
entity.ToTable("ContactIdempotency");
@@ -56,3 +56,18 @@ public class IdempotencyRecord
public DateTimeOffset CreatedAt { get; set; }
public int StatusCode { get; set; }
}
/// <summary>
/// The CMS-controlled on/off switch of the contact form (a singleton row, id 1). While no row
/// exists the switch is off. It is the second layer of the gate; the host switch
/// (<c>Contact:Enabled</c>) is the first.
/// </summary>
public class ContactSettings
{
public const int SingletonId = 1;
public int Id { get; set; } = SingletonId;
public bool Enabled { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
public Guid UpdatedByUserId { get; set; }
}