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

tags

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tags is the one place a Contact's Tags are listed, applied and removed (ADR 0016). A Tag is a presence-only, workspace-scoped label (GLOSSARY); it is auto-created the first time it is applied, like a Custom field. Handlers on /site and /api stay thin adapters: scope check, call, map. Tag-based targeting is not here — it is the has-Tag rule of the segments engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContactNotFound: no such Contact in this Workspace.
	ErrContactNotFound = validation.Refuse("tags: contact not found", "errors.contact_not_found")
	// ErrInvalidName: the Tag name is blank.
	ErrInvalidName = validation.Refuse("tags: name is required", "errors.name_required")
	// ErrNotFound: no such Tag in this Workspace.
	ErrNotFound = validation.Refuse("tags: tag not found", "errors.tag_not_found")
)

Domain errors. Callers match with errors.Is.

Functions

This section is empty.

Types

type Module

type Module struct{}

Module is the tags module. It holds no state: every call receives the Workspace-scoped client (ADR 0017) built by the entry point, so the module writes no Workspace predicate and cannot name another Workspace.

func New

func New() *Module

New builds the tags module.

func (*Module) Apply

func (m *Module) Apply(ctx context.Context, s *ent.Scoped, contactID int64, name string) (*ent.Tag, error)

Apply gives the Contact the named Tag, creating the Tag on first use. It is idempotent: applying a Tag the Contact already has changes nothing. The Contact is checked before anything is written, so a failed apply creates no Tag.

func (*Module) Delete

func (m *Module) Delete(ctx context.Context, s *ent.Scoped, id int64) error

Delete removes a Tag from the catalogue, and from every Contact that has it, unless a Segment rule or an Automation step names it, an archived Automation's too: then it returns an *inuse.Error naming those Segments and Automations (ADR 0049), because both name the Tag and would silently stop matching or applying. A missing Tag is ErrNotFound.

func (*Module) ForContact

func (m *Module) ForContact(ctx context.Context, s *ent.Scoped, contactID int64) ([]*ent.Tag, error)

ForContact returns the Tags a Contact has, ordered by name.

func (*Module) List

func (m *Module) List(ctx context.Context, s *ent.Scoped) ([]*ent.Tag, error)

List returns the Workspace's Tag catalogue ordered by name.

func (*Module) Remove

func (m *Module) Remove(ctx context.Context, s *ent.Scoped, contactID int64, name string) error

Remove takes the named Tag off the Contact. It is idempotent: a Tag the Contact does not have (or that does not exist) is a no-op. The Tag stays in the catalogue.

func (*Module) Set

func (m *Module) Set(ctx context.Context, s *ent.Scoped, contactID int64, names []string) error

Set makes the named Tags the Contact's complete set: it applies the missing ones (creating them on first use) and removes the rest. Blank and repeated names are dropped, so a form's empty chip changes nothing.

Jump to

Keyboard shortcuts

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