Contact: mail via achtergrondservice met claim, backoff en maximum (CMS-U5)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 15:28:24 +01:00
co-authored by Claude Sonnet 5.5
parent 728fc08db8
commit bc7936034c
28 changed files with 1273 additions and 107 deletions
@@ -38,9 +38,41 @@ public class ContactOptions
public ContactCaptchaOptions Captcha { get; set; } = new();
/// <summary>
/// Where the notification mail for a genuine message goes. Supply it through the environment
/// (<c>Contact__RecipientEmail</c>); it is never part of committed configuration and never exposed to a client.
/// </summary>
public string? RecipientEmail { get; set; }
public ContactMailOptions Mail { get; set; } = new();
public string EffectiveSiteId => string.IsNullOrWhiteSpace(SiteId) ? "default" : SiteId.Trim();
}
/// <summary>How the background sender works (section <c>Contact:Mail</c>).</summary>
public class ContactMailOptions
{
/// <summary>How often the sender looks for mail that is due, besides being woken by a new message.</summary>
public int SweepSeconds { get; set; } = 120;
/// <summary>Automatic attempts per message; after that it stays failed until an administrator resends.</summary>
public int MaxAttempts { get; set; } = 6;
/// <summary>Wait before attempt n+1 after attempt n failed (the last value repeats). Default 5 min, 15 min, 1 h, 6 h, 24 h.</summary>
public int[] BackoffMinutes { get; set; } = [5, 15, 60, 360, 1440];
/// <summary>A claimed message is not claimed again by another instance for this long.</summary>
public int ClaimMinutes { get; set; } = 5;
public int BatchSize { get; set; } = 20;
public TimeSpan BackoffAfter(int attempts)
{
var steps = BackoffMinutes is { Length: > 0 } ? BackoffMinutes : [5];
return TimeSpan.FromMinutes(Math.Max(1, steps[Math.Clamp(attempts - 1, 0, steps.Length - 1)]));
}
}
public class ContactCaptchaOptions
{
public bool Enabled { get; set; }