Skip to content
quarry Artifact [b252d850ca]
Login

Artifact [b252d850ca]

Artifact b252d850ca502c68c6d3f0c68197672b0604e027595e74d68b3dacc54c51b1ff:


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 one from a team that
// team's mark and name, and neither ever wears 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, credential and forge-invite mail is the application's;
// content about one repository is that repository's; what a team does or
// says, to its members, is the team's.
type mailOrigin string

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

// 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"
	kindEmailProposed   = "account.email-proposed"
	kindInviteRedeemed  = "account.invite-redeemed"
	kindAccessChanged   = "account.access-changed"
)

// The kinds sent as a team's mail (accountMail.Kind with Team set). They
// are permission mail like access-changed, so they follow the same policy:
// transactional, always sent, no preference to turn them off (see
// transactional.go); the account family, not a content family.
const (
	kindTeamAdded       = "team.added"
	kindTeamRemoved     = "team.removed"
	kindTeamRoleChanged = "team.role-changed"
)

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"},
	kindEmailProposed:   {fromApp, "a security notice that an administrator proposed a new address for the account"},
	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"},
	"probe.alert":       {fromApp, "the outside probe watches the whole forge, not one repository"},
	// Team: what a team does to, or says to, its members.
	kindTeamAdded:         {fromTeam, "the team put you in it: its floor now applies on every repository under it"},
	kindTeamRemoved:       {fromTeam, "the team took you out of it: its floor no longer applies"},
	kindTeamRoleChanged:   {fromTeam, "your role or capabilities in the team changed"},
	"quarry-mention.team": {fromTeam, "someone named you in the team's own chat"},
	// 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"},
}