Skip to content
quarry Artifact [acfcc53218]
Login

Artifact [acfcc53218]

Artifact acfcc532187bb4df445daf090fd2acc540dbc1f395323faa8b3825cae06664de:


package api

// Who an email is FROM decides what its header carries: an email from the
// application wears the application's wordmark, an email from a repository
// wears that repository's mark and lowercase name and never the wordmark.
// Every email quarry sends is listed here, once, with the reason; nothing
// is inferred from the shape of a template. The footer of every email, of
// either kind, carries the wordmark.
//
// The rule: account, permission and multi-repository mail is the
// application's; content about one repository is that repository's.
type mailOrigin string

const (
	fromApp  mailOrigin = "app"
	fromRepo mailOrigin = "repo"
)

// The kinds sent as account mail (accountMail.Kind).
const (
	kindInvite          = "account.invite"
	kindReset           = "account.reset"
	kindPasswordChanged = "account.password-changed"
	kindEmailCode       = "account.email-code"
	kindEmailChanged    = "account.email-changed"
	kindEmailSet        = "account.email-set"
	kindInviteRedeemed  = "account.invite-redeemed"
	kindAccessChanged   = "account.access-changed"
	kindTeamMembership  = "account.team-membership"
)

type mailKind struct {
	From   mailOrigin
	Reason string
}

// mailKinds is the one table. The notify workflows are keyed by their
// workflow name; the probe's alerts (scripts/probe) are listed for the
// record, and its own test holds its header to the application's.
var mailKinds = map[string]mailKind{
	// Application: about an account, a credential or a permission.
	kindInvite:          {fromApp, "an invitation to the forge itself; the person has no repository relationship yet"},
	kindReset:           {fromApp, "a credential for the account, not content of any repository"},
	kindPasswordChanged: {fromApp, "a security notice about the account"},
	kindEmailCode:       {fromApp, "confirms an address for the account"},
	kindEmailChanged:    {fromApp, "a security notice sent to the address the account is leaving"},
	kindEmailSet:        {fromApp, "an administrator set the account's address"},
	kindInviteRedeemed:  {fromApp, "tells whoever runs invitations that a person joined the forge"},
	kindAccessChanged:   {fromApp, "a permission change: the application grants access, even when it names a repository"},
	kindTeamMembership:  {fromApp, "a team grants a floor across several repositories, so no single repository sends it"},
	"probe.alert":       {fromApp, "the outside probe watches the whole forge, not one repository"},
	// Repository: content about one repository, in its own words.
	"quarry-mention":     {fromRepo, "someone named you in a repository's chat or forum"},
	"quarry-forum-reply": {fromRepo, "a reply in one repository's forum thread"},
	"quarry-landing":     {fromRepo, "a landing, or its CI, in one repository"},
	"quarry-activity":    {fromRepo, "a digest keyed per repository (digestKey payload.repo), never spanning several"},
}