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
@@ -45,8 +45,20 @@ public class ContactModule : IModule
services.AddSingleton<IContactTokenService, ContactTokenService>();
services.AddSingleton<ICaptchaVerifier, NullCaptchaVerifier>();
services.AddScoped<IContactMailSender, NoOpContactMailSender>();
services.AddScoped<IContactFormGate, HostFlagContactFormGate>();
// Gate: the form is open only if the host switch AND the CMS switch are on. The host switch
// is asked first, so with it off the database is never touched.
services.AddSingleton<ContactSettingsCache>();
services.AddScoped<IContactSettingsService, ContactSettingsService>();
services.AddScoped<HostFlagContactFormGate>();
services.AddScoped<CmsFlagContactFormGate>();
services.AddScoped<IContactFormGate>(sp => new CompositeContactFormGate(
[
sp.GetRequiredService<HostFlagContactFormGate>(),
sp.GetRequiredService<CmsFlagContactFormGate>(),
]));
services.AddScoped<IContactAdminService, ContactAdminService>();
services.AddScoped<ContactRouteFilter>();
services.AddScoped<ContactAdminRouteFilter>();
services.AddHostedService<ContactRetentionService>();
// The contact details of the OpenAPI document (named options of document 'v1', so the shared
@@ -62,6 +74,8 @@ public class ContactModule : IModule
Window(config, "ContactForm", 5, 600, context));
limiter.AddPolicy(ContactMessagesController.TokenPolicy, context =>
Window(config, "ContactToken", 20, 600, context));
limiter.AddPolicy(ContactMessagesAdminController.ResendPolicy, context =>
Window(config, "ContactResend", 5, 600, context));
});
}