Contactmodule: token- en inzendroute met spamafhandeling, idempotentie en retentietaak
Nieuwe module SlpModularCms.Modules.Contact met eigen DbContext en migratie InitialCreate. GET contact-messages/token en POST contact-messages zijn publiek ([PublicSiteEndpoint]), geven bij echte inzendingen, spam en herhalingen hetzelfde 202 en slaan spam apart op (30 dagen, dagplafond). Standaard staat de module uit (Contact:Enabled=false, 404 met lege body, geen databasetoegang) totdat de rate limiting per client op de basisbranch staat; de rate-limit-sleutel zit in een enkele functie zodat dat later een regel wijzigen is. Mail zit achter een seam (nog een no-op). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SlpModularCms.Modules.Contact.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("MySQL:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactIdempotency",
|
||||
columns: table => new
|
||||
{
|
||||
SiteId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Key = table.Column<Guid>(type: "char(36)", nullable: false),
|
||||
CreatedAt = table.Column<DateTimeOffset>(type: "datetime", nullable: false),
|
||||
StatusCode = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactIdempotency", x => new { x.SiteId, x.Key });
|
||||
})
|
||||
.Annotation("MySQL:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactMessages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
||||
SiteId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
ReceivedAt = table.Column<DateTimeOffset>(type: "datetime", nullable: false),
|
||||
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Email = table.Column<string>(type: "varchar(254)", maxLength: 254, nullable: false),
|
||||
Subject = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Message = table.Column<string>(type: "varchar(2000)", maxLength: 2000, nullable: false),
|
||||
Status = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false),
|
||||
MailStatus = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false),
|
||||
MailError = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true),
|
||||
MailAttempts = table.Column<int>(type: "int", nullable: false),
|
||||
NextMailAttemptAt = table.Column<DateTimeOffset>(type: "datetime", nullable: true),
|
||||
RetentionUntil = table.Column<DateTimeOffset>(type: "datetime", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactMessages", x => x.Id);
|
||||
})
|
||||
.Annotation("MySQL:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactIdempotency_CreatedAt",
|
||||
table: "ContactIdempotency",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactMessages_RetentionUntil",
|
||||
table: "ContactMessages",
|
||||
column: "RetentionUntil");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactMessages_SiteId_Status_ReceivedAt",
|
||||
table: "ContactMessages",
|
||||
columns: new[] { "SiteId", "Status", "ReceivedAt" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactIdempotency");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactMessages");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user