Help us shape the future of Go! Take the 2026 Go Developer Survey

consent

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func RecordUnsubscribe(ctx context.Context, bus *events.Bus, target tracking.UnsubTarget) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL