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

suppression

package
v0.3.5 Latest Latest
Warning

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

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

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

View Source
const (
	BounceKindPermanent = "permanent"
	BounceKindTransient = "transient"
)

Bounce kinds. Only a permanent (hard) bounce suppresses; a transient (soft) one, such as a full mailbox, is temporary.

View Source
const (
	EventBounced    = "email.bounced"
	EventComplained = "email.complained"
)

Names of the delivery events that can suppress; the bus's event names are these.

Variables

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

func Add(ctx context.Context, s *ent.Scoped, e Entry) error

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

func AddManual(ctx context.Context, s *ent.Scoped, destination string) (*ent.Suppression, error)

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

func EraseContact(ctx context.Context, s *ent.Scoped, contactID int64) error

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

List returns one page of the Workspace's active Suppressions, newest first, or of its lifted ones when lifted is true.

func NormalizeDestination

func NormalizeDestination(dest string) string

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.

func Remove

func Remove(ctx context.Context, s *ent.Scoped, id int64) error

Remove lifts an active Suppression of the scoped Workspace by id: the row stays with its lift time and the destination can receive mail again. A missing or already lifted one is ErrNotFound.

Types

type Entry

type Entry struct {
	Destination string
	Reason      entsuppression.Reason
	ContactID   int64
}

Entry is one Suppression to add. ContactID is the Contact the destination belongs to, when known (display only); zero means none.

Jump to

Keyboard shortcuts

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