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>
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
namespace SlpModularCms.Modules.Contact.Data.Entities;
|
|
|
|
public enum ContactMessageStatus
|
|
{
|
|
New,
|
|
Read,
|
|
Archived,
|
|
Spam,
|
|
Converted,
|
|
}
|
|
|
|
public enum ContactMailStatus
|
|
{
|
|
/// <summary>Waiting to be mailed (also the state while no mail sender is available).</summary>
|
|
Pending,
|
|
Sent,
|
|
Failed,
|
|
/// <summary>Never mailed on purpose (spam).</summary>
|
|
NotApplicable,
|
|
}
|
|
|
|
/// <summary>
|
|
/// A message sent through the website's contact form. Has its own id and status so that it can
|
|
/// later be turned into an assignment (quotes, invoices); that is not built yet.
|
|
/// </summary>
|
|
public class ContactMessage
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string SiteId { get; set; } = string.Empty;
|
|
public DateTimeOffset ReceivedAt { get; set; }
|
|
public string Name { get; set; } = string.Empty;
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
/// <summary>Opaque value chosen by the site (a package id, a slug, or 'other').</summary>
|
|
public string Subject { get; set; } = string.Empty;
|
|
|
|
public string Message { get; set; } = string.Empty;
|
|
public ContactMessageStatus Status { get; set; }
|
|
public ContactMailStatus MailStatus { get; set; }
|
|
|
|
/// <summary>Short error code of the last failed mail attempt (never an address or content).</summary>
|
|
public string? MailError { get; set; }
|
|
|
|
public int MailAttempts { get; set; }
|
|
public DateTimeOffset? NextMailAttemptAt { get; set; }
|
|
|
|
/// <summary>Fixed at insert: a later configuration change does not apply retroactively.</summary>
|
|
public DateTimeOffset RetentionUntil { get; set; }
|
|
}
|
|
|
|
/// <summary>Remembers an Idempotency-Key for 24 hours. Holds no request content.</summary>
|
|
public class IdempotencyRecord
|
|
{
|
|
public string SiteId { get; set; } = string.Empty;
|
|
public Guid Key { get; set; }
|
|
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; }
|
|
}
|