Documentation
¶
Overview ¶
Package suppression is the one place Suppression rows are written, listed and removed (ADR 0015, GLOSSARY "Suppression"): the hard, global do-not-send registry keyed by (channel, destination). The bus subscriber, the manual add and the site handlers all go through it, so the "insert, ignore on conflict" statement exists once. Unsubscribe and confirm stay in consent; eligibility reads Suppression with its own SQL.
Index ¶
- Constants
- Variables
- func Add(ctx context.Context, s *ent.Scoped, e Entry) error
- func AddManual(ctx context.Context, s *ent.Scoped, destination string) (*ent.Suppression, error)
- func EraseContact(ctx context.Context, s *ent.Scoped, contactID int64) error
- func ForEvent(name, bounceKind string) (entsuppression.Reason, bool)
- func List(ctx context.Context, s *ent.Scoped, p pagination.Params, lifted bool) (pagination.Page[*ent.Suppression], error)
- func NormalizeDestination(dest string) string
- func Remove(ctx context.Context, s *ent.Scoped, id int64) error
- type Entry
Constants ¶
const ( BounceKindPermanent = "permanent" BounceKindTransient = "transient" )
Bounce kinds. Only a permanent (hard) bounce suppresses; a transient (soft) one, such as a full mailbox, is temporary.
const ( EventBounced = "email.bounced" EventComplained = "email.complained" )
Names of the delivery events that can suppress; the bus's event names are these.
Variables ¶
var ( // ErrDestinationEmpty: the destination is blank after normalization. ErrDestinationEmpty = errors.New("suppression: destination must not be empty") // ErrNotFound: no such Suppression in this Workspace. ErrNotFound = errors.New("suppression: not found") )
Functions ¶
func Add ¶
Add suppresses an email destination in the scoped Workspace with one insert. It is idempotent per (channel, destination): an existing active entry keeps its reason. A lifted entry does not count (ADR 0049): the destination is suppressed anew in a new row.
func AddManual ¶
AddManual is Add with the manual reason (an Owner's or an API caller's request), and returns the entry, the existing one when the destination was already suppressed.
func EraseContact ¶
EraseContact is the Suppression part of the Contact's Erasure: its lifted rows are deleted, since a lifted one refuses nothing any more, and its active rows only lose the Contact reference, because they are keyed by destination and keep refusing the address.
func ForEvent ¶
func ForEvent(name, bounceKind string) (entsuppression.Reason, bool)
ForEvent is the rule that decides whether a delivery event suppresses its address, and why: a complaint always does, a bounce only when permanent (bounceKind), anything else never. Unsubscribe is not a Suppression (ADR 0001).
func List ¶
func List(ctx context.Context, s *ent.Scoped, p pagination.Params, lifted bool) (pagination.Page[*ent.Suppression], error)
List returns one page of the Workspace's active Suppressions, newest first, or of its lifted ones when lifted is true.
func NormalizeDestination ¶
NormalizeDestination is the single definition of "normalized destination": lower-cased and trimmed. Suppression and Unsubscribe rows store destinations this way, and every lookup must apply it so the readers of those rows agree on one form.