mailgroups

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mailgroups defines email audiences: saved rules over platform users plus manual addresses, with a suppression list and signed one-click unsubscribe tokens.

Index

Constants

This section is empty.

Variables

View Source
var Roles = []string{"owner", "admin", "operator", "viewer"}

Roles a rule can select.

Functions

func Mask

func Mask(email string) string

Mask hides most of an address for previews: "s***@example.com".

func Normalize

func Normalize(addr string) string

Normalize lowercases and trims an address.

func SignUnsubscribe

func SignUnsubscribe(key []byte, email string) string

SignUnsubscribe returns a token naming email that only this instance can have produced. It never expires: an unsubscribe link must keep working.

func ValidAddress

func ValidAddress(a string) error

ValidAddress reports an error unless a is one bare email address.

func VerifyUnsubscribe

func VerifyUnsubscribe(key []byte, token string) (string, bool)

VerifyUnsubscribe returns the address a token names when its signature holds.

Types

type Directory

type Directory struct {
	Users []User
	// ProjectTeams maps a project id onto the team that owns it.
	ProjectTeams map[string]string
}

Directory is everything Resolve needs to know about the instance.

type Recipient

type Recipient struct {
	Email       string `json:"email"`
	UserID      string `json:"user_id"`
	DisplayName string `json:"display_name"`
	Role        string `json:"role"`
}

Recipient is one resolved address.

func Resolve

func Resolve(d Directory, r Rules, now time.Time) []Recipient

Resolve returns the deduplicated recipients the rules select, sorted by address. Suppression is applied separately by Split.

func Split

func Split(rcpts []Recipient, suppressed map[string]bool, honor bool) (send, held []Recipient)

Split separates suppressed recipients from deliverable ones. When honor is false (system mail) nobody is suppressed.

type Rules

type Rules struct {
	AllUsers         bool     `json:"all_users"`
	Roles            []string `json:"roles"`
	Teams            []string `json:"teams"`
	Projects         []string `json:"projects"`
	EmailDomains     []string `json:"email_domains"`
	InactiveDays     int      `json:"inactive_days"`
	ExtraAddresses   []string `json:"extra_addresses"`
	ExcludeAddresses []string `json:"exclude_addresses"`
}

Rules selects recipients. A user is included when any selector matches (AllUsers, Roles, Teams, Projects, EmailDomains); InactiveDays then narrows the result, and alone selects every user inactive that long. ExtraAddresses are added as-is; ExcludeAddresses are always removed.

func (Rules) Validate

func (r Rules) Validate() error

Validate checks rules are well formed.

type User

type User struct {
	ID          string
	Email       string
	DisplayName string
	Role        string
	TeamIDs     []string
	LastLoginAt *time.Time
	CreatedAt   time.Time
}

User is the slice of a platform account the rules look at.

Jump to

Keyboard shortcuts

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