Documentation
¶
Overview ¶
Package consent holds the use-case modules that change a destination's consent state. It is shared by the public unsubscribe link and the external API so both produce identical effects.
Index ¶
- Variables
- func RecordConfirmation(ctx context.Context, bus *events.Bus, target tracking.ConfirmTarget, ip string) error
- func RecordUnsubscribe(ctx context.Context, bus *events.Bus, target tracking.UnsubTarget) error
- func Unsubscribe(ctx context.Context, bus *events.Bus, s *ent.Scoped, ...) (*ent.Unsubscribe, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDestinationEmpty: the destination is blank after normalization. ErrDestinationEmpty = errors.New("consent: destination must not be empty") // ErrInvalidSource: the sending source is not broadcasts, everything or automation:<id>. ErrInvalidSource = errors.New("consent: sendingSource must be broadcasts, everything or automation:<id>") // ErrUnknownAutomation: the automation:<id> source names no Automation of this Workspace. ErrUnknownAutomation = errors.New("consent: unknown automation in sendingSource") )
Functions ¶
func RecordConfirmation ¶
func RecordConfirmation(ctx context.Context, bus *events.Bus, target tracking.ConfirmTarget, ip string) error
RecordConfirmation writes the derived Confirmation read-model row (provenance double_opt_in) and publishes the immutable marketing.confirmed Event in one transaction (ADR 0013) — the positive mirror of RecordUnsubscribe. It is keyed by destination, so it records even if the contact was deleted between send and click. The existence check makes a repeated POST (mailbox retry, double click) a complete no-op: the confirmation stands and no second Event is logged.
func RecordUnsubscribe ¶
RecordUnsubscribe writes a per-(channel, destination, sending source) opt-out (ADR 0001) from a signed token — no contact-row lookup, so the opt-out records even if the contact was deleted between send and click (the point of destination-keying). The default in-email link is scoped to its sending source; "everything" is the deliberate escalation. All effects (the row, the broadcast counter, the automation enrollment exit, and the engagement event) live in one transaction gated on the existence check, so a repeated POST (mailbox retry or a double click) is a complete no-op and concurrent POSTs are counted exactly once.
func Unsubscribe ¶
func Unsubscribe(ctx context.Context, bus *events.Bus, s *ent.Scoped, destination, source string) (*ent.Unsubscribe, error)
Unsubscribe records an opt-out of destination from a sending source, with the same effects as the unsubscribe link (RecordUnsubscribe): the row, the confirmation reset on "everything", the automation exit and the engagement event, atomically and idempotently. When the destination is a Contact of the Workspace the event is attributed to it. The source is validated first.
Types ¶
This section is empty.