feat(identity): add server sessions and audited mail recovery

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 11:03:46 +03:00
1 parent 20c03288d6
commit 4ee53d9a74
58 files changed
+5359 -567

No files matched your search

@@ -196,6 +196,12 @@ type Delivery struct {
FailureCount int32
// Set when the bodies of a token mail were cleared after the delivery reached a terminal status, so a database dump holds no live or dead token.
BodyRedactedAt pgtype.Timestamptz
// Database time of the latest audited operator authorization to retry a terminal unknown delivery; it does not replace the original send history.
ManualRetryAuthorizedAt pgtype.Timestamptz
// Database time when the first provider call of the latest manual authorization started; this is a single-use/recovery marker and never resets the provider deduplication window.
ManualRetryStartedAt pgtype.Timestamptz
// Attempt count when the latest provider call started. Equality with attempt_count means its result was not recorded; a greater attempt_count means a provider result was stored after that send-start.
SendStartedAttemptCount pgtype.Int4
}
type DeliveryAttempt struct {
@@ -211,6 +217,21 @@ type DeliveryAttempt struct {
NextAttemptAt pgtype.Timestamptz
}
// Append-only record of an operator decision to retry a terminal unknown mail delivery after its provider deduplication window. No foreign key so history survives account deletion.
type DeliveryRetryDecision struct {
DecisionID int64
// Opaque ID of the delivery whose current unknown attempt was authorized for another send cycle.
DeliveryID pgtype.UUID
AttemptCount int32
// Operator handle in the form operator:<handle>; never an email address or credential.
Actor string
// Must be true: after the provider key expires, reusing it does not guarantee deduplication.
DuplicateRiskAcknowledged bool
// True when this decision also cleared an expired worker lease after a manual send began but its result was not recorded.
PreviousLeaseExpired bool
DecidedAt pgtype.Timestamptz
}
type EmailToken struct {
ID pgtype.UUID
UserID pgtype.UUID