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 ¶
- Variables
- type Module
- func (m *Module) Apply(ctx context.Context, s *ent.Scoped, contactID int64, name string) (*ent.Tag, error)
- func (m *Module) Delete(ctx context.Context, s *ent.Scoped, id int64) error
- func (m *Module) ForContact(ctx context.Context, s *ent.Scoped, contactID int64) ([]*ent.Tag, error)
- func (m *Module) List(ctx context.Context, s *ent.Scoped) ([]*ent.Tag, error)
- func (m *Module) Remove(ctx context.Context, s *ent.Scoped, contactID int64, name string) error
- func (m *Module) Set(ctx context.Context, s *ent.Scoped, contactID int64, names []string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrContactNotFound: no such Contact in this Workspace. ErrContactNotFound = errors.New("tags: contact not found") // ErrInvalidName: the Tag name is blank. ErrInvalidName = errors.New("tags: name is required") // ErrNotFound: no such Tag in this Workspace. ErrNotFound = errors.New("tags: 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 (*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 ¶
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) Remove ¶
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.