mentions

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 15 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 mentions holds whom a Destination mentions. From 0.2.0 that is its Mention entries (C-28.FR-1): an ordered list, each entry one target — everyone in the chat with a word, a person, a messenger group, a Team, the Teams of the Alert Group, or the On-call of a Team or of each Team of the Alert Group — and the Loud events it applies to, limited to what the Destination's Connection can mention (C-28.FR-2), with the L1 Mention settings of C-12.FR-8 derived from them and converted into them until 0.3.0 (C-28.FR-5). It resolves the symbolic Mentions of a Loud message into targets (C-28.FR-3, FR-4): the entries for its event — a person by their Account link in the Destination's identity space and left out without one, a Team by its Team mention for the Connection and nobody without one, the On-call by the Team's main Schedule at the moment of the event — and the Owner the lifecycle event recorded or its previous Owner, named as L1 named them. A User is named by the username of their Account link in the Destination's identity space — through a Bridge by the link's messenger user id and display name (C-22.FR-16), and in Slack by the link's user id as <@id>, which its adapter renders (C-24.FR-6) — otherwise by the Muster display name, which mentions nobody; the footer of a message names its user the same way (C-12.FR-12). A group — a group entry or a Team mention — is named by its name and, in Slack, the user group's id, which the Slack adapter writes as <!subteam^id> (C-24.FR-6); everyone in the chat by its symbolic name; a Bridge receives both as entries of their own kind (C-22.FR-16). It imports neither internal/schedules nor internal/teams: the On-call and the Team mentions come through the interfaces it declares, which internal/runtime wires (ADR-0016). Storing a Destination is internal/destinations', and rendering a target in a messenger's syntax is its adapter's.

Index

Constants

View Source
const (
	TargetTeam                   = "team"
	TargetTeamsFromLabel         = "teams_from_label"
	TargetOnCallOfTeam           = "on_call_of_team"
	TargetOnCallOfTeamsFromLabel = "on_call_of_teams_from_label"
)

The kinds of an entry's target beside TargetEveryone, TargetUser and TargetGroup (MentionTargetKind): a Team, the Teams of the Alert Group, and the On-call of a Team's main Schedule or of each Team of the Alert Group. TargetTeam is also the kind of a resolved Target of an outgoing webhook, which carries a Team as data (C-15.FR-11).

View Source
const (
	ReasonTelegramNoGroups      = "telegram_no_groups"
	ReasonUsergroupsReadMissing = "usergroups_read_missing"
	ReasonBridgeNoGroupMentions = "bridge_no_group_mentions"
	ReasonBridgeNotDeclared     = "bridge_not_declared"
	ReasonMessengerHasNoToken   = "messenger_has_no_token"
)

The reasons a Connection cannot mention a target (MentionUnavailableReason, C-28.FR-2), as internal/teams names those of the Team mentions.

View Source
const (
	KindNewAlertGroup = "new_alert_group"
	KindNewAlerts     = "new_alerts"
	KindReopen        = "reopen"
	KindAckTimeout    = "ack_timeout"
	KindSnoozeEnded   = "snooze_ended"
	KindRiseToUrgent  = "rise_to_urgent"
)

The kinds of Loud events a Destination sets Mentions for, as the lifecycle event tables name them (C-09.FR-22).

View Source
const (
	Owner         = "owner"
	PreviousOwner = "previous_owner"
)

The symbolic Mentions that name a person of the Alert Group rather than a setting: the Owner, and the previous Owner of a Takeover.

View Source
const (
	EveryoneNone    = "none"
	EveryoneChannel = "channel"
	EveryoneAll     = "all"
	EveryoneHere    = "here"
)

The choices of everyone in the chat: nobody, or the word of the messenger.

View Source
const (
	TypeMattermost = "mattermost"
	TypeTelegram   = "telegram"
	TypeWebhook    = "webhook"
	TypeBridge     = "bridge"
	TypeSlack      = "slack"
)

The Destination types.

View Source
const (
	TargetEveryone = "everyone"
	TargetGroup    = "group"
	TargetUser     = "user"
)

The kinds of a Target.

View Source
const (
	CodeRequired      = "required"
	CodeInvalidFormat = "invalid_format"
	CodeUnsupported   = "unsupported"
	CodeUnknownID     = "unknown_id"
	CodeDuplicate     = "duplicate"
)

The codes of FieldError, as the API names them.

View Source
const (
	ReasonNoAccountLink             = "no_account_link"
	ReasonBridgeCannotMentionPeople = "bridge_cannot_mention_people"
	ReasonMessageTooLong            = "message_too_long"
)

The reasons a person whom a Mention entry names is not mentioned as their messenger mentions them (MentionNotDeliveredReason, C-28.FR-3): no Account link in the Destination's identity space, which leaves them out of the message, a bridge without native_mentions, or an Account link whose marker the bridge's message cannot build, which names them by the plain name (C-22.FR-16), or a bridge message whose Mention line left their Mention out for its length (C-12.FR-11) — also the reason of a group or everyone in the chat left out so.

View Source
const CodeMentionUnsupported = "mention_unsupported"

CodeMentionUnsupported is the code of FieldError of a target the Destination's Connection cannot mention.

View Source
const EventStormStarted = "storm_started"

EventStormStarted is the Loud event of the first publication of a Storm summary (C-28.FR-7), which only Mention entries name; the six kinds of L1 are the others.

View Source
const EveryoneEveryone = "everyone"

EveryoneEveryone is the mention of everyone that only an entry names: Mattermost and Slack have no such token, a bridge may declare it, and an outgoing webhook takes it as data.

View Source
const MaxEntries = 100

MaxEntries is the most Mention entries a Destination has (the maxItems of mention_entries), which the request validation of the API holds; the entry a Team adds is not added to a Destination that has them, so that a read sent back stays within it.

Variables

Events are the Loud events a Mention entry applies to, in the order of the API (MentionEvent, C-28.FR-1).

Kinds are the kinds of MentionSettings, in the order of the API.

TargetKinds are the kinds of an entry's target, in the order of the API.

Functions

func Can

func Can(destinationType string, c Connection, t EntryTarget) (bool, string)

Can reports whether a Destination of the type on the Connection c can mention the target now, and the reason when it cannot (C-28.FR-2): people and the On-call on every type; everyone with channel, here and all in Mattermost, with channel and here in Slack, with the words a bridge declares in everyone_mentions, never in Telegram; groups and Teams in Mattermost, in Slack while its last check found usergroups:read, through a bridge that declares group mentions, never in Telegram. A bridge that is a Notification gateway only mentions neither. An outgoing webhook takes every target, as data.

func IdentitySpace

func IdentitySpace(destinationType string, connection *int64) string

IdentitySpace is the identity space of a Destination's messenger: every Telegram link, or the Mattermost, Bridge or Slack links of its Connection (C-22.FR-15, C-24.FR-6); an outgoing webhook has none, so that a User is named by their display name.

func SameForm

func SameForm(destinationType string, stored []EntryInput, set Settings) bool

SameForm reports whether the Mention settings of a request equal the L1 form of the stored entries of a Destination of the type, as a client that sends back what it read sends them: such a request changes nothing and is not validated again, so that a User deleted since, whom the form shows, does not refuse it (C-28.FR-5).

func SlackUserGroupID

func SlackUserGroupID(id string) bool

SlackUserGroupID reports whether id has the form of a Slack user group's id (F-125), the only group a Slack message can mention (C-24.FR-6).

Types

type Check

type Check struct {
	DestinationType string
	Connection      string
	Entries         []EntryInput
	Stored          []EntryInput
}

Check is the Mention entries of a save to validate: the Destination's type and Connection (public_id, empty for an outgoing webhook), the entries, and the Destination's entries before the save, nil on a creation.

type Connection

type Connection struct {
	ID             int64
	Type           string
	UsergroupsRead bool
	GroupMentions  bool
	NativeMentions bool
	Messenger      bool
	Everyone       []string
}

Connection is what a Destination's Connection can mention (C-28.FR-2): its type, whether the last check of a Slack Connection found usergroups:read, and from a Bridge's stored info whether it declares group mentions and native mentions — neither while no info was read — the role messenger and which mentions of everyone.

type DBTX

type DBTX = dbgen.DBTX

DBTX is the pool, connection or transaction the package reads through.

type Entry

type Entry struct {
	ID       int64
	Position int
	EntryInput
	User              *UserRef
	Team              *TeamRef
	Available         bool
	UnavailableReason string
	ResolvesTo        []Resolution
}

Entry is a Mention entry as a read gives it (MentionEntry): its id and position, its input, the User or the Team it names, whether the Destination's Connection can mention its target now, with the reason when it cannot, and what it mentions now.

type EntryDestination

type EntryDestination struct {
	ID         int64
	Type       string
	Connection string
}

EntryDestination is a Destination whose entries a read gives: its id, its type and its Connection by public_id, empty for an outgoing webhook.

type EntryInput

type EntryInput struct {
	Target EntryTarget `json:"target"`
	Events []string    `json:"events"`
}

EntryInput is a Mention entry as a save writes it (MentionEntryInput): its target and the Loud events it applies to, all of them for an entry that names none.

func FromSettings

func FromSettings(destinationType string, set Settings) []EntryInput

FromSettings turns the Mention settings of L1 into entries with the same effect, as the 0.2.0 migration does (C-28.FR-5, migration 0043): each target chosen — the everyone choice other than none, each chosen User, each group, among those L1 took on the Destination type — becomes one entry for the kinds it was chosen for, with storm_started where new_alert_group is among them, since an L1 Storm summary mentioned the targets of new_alert_group; the entries are everyone, then the Users, then the groups, each in the order L1 listed them, kind by kind. Settings that mention nobody give no entry.

func Inputs

func Inputs(entries []Entry) []EntryInput

Inputs are the inputs of the entries of a read.

func MergeSettings

func MergeSettings(destinationType string, stored []EntryInput, set Settings) []EntryInput

MergeSettings is the entries of a request that sends the Mention settings of L1 without entries, on an update of a Destination of the type whose entries are stored (C-28.FR-5): nothing changes when the settings equal the L1 form of the stored entries, so that a client that sends back what it read loses nothing; otherwise the conversion of FromSettings replaces exactly the stored entries that L1 can express, every other entry staying after them in its order — a Slack user group, a mention of everyone that L1 had not, an entry for storm_started alone, Teams and On-calls — and a target present before and after keeps its stored storm_started rather than the conversion's rule; such a target stored in an entry that L1 cannot express merges into the converted one. A kind of a stored entry that the form does not show — a second mention of everyone for a kind, of which the form shows the first — stays on it unless the request changed that kind's everyone choice, so that a save from the L1 editor that did not touch the kind loses no Mention.

type EntryRef

type EntryRef struct {
	ID       int64
	Position int
	Target   EntryTarget
}

EntryRef is the Mention entry that named a person: its id, its position and its target, which is the entry's identity across saves of its Destination — a save writes every entry again, and each target appears once.

type EntryTarget

type EntryTarget struct {
	Kind     string `json:"kind"`
	Everyone string `json:"everyone,omitempty"`
	UserID   string `json:"user_id,omitempty"`
	Group    string `json:"group,omitempty"`
	GroupID  string `json:"group_id,omitempty"`
	TeamID   string `json:"team_id,omitempty"`
}

EntryTarget is the target of a Mention entry as a save writes it and the Audit log diff of its Destination shows it, with the fields of its kind: the word of everyone, a User by public_id, a group by its name with a Slack user group's id, or a Team by public_id.

type FieldError

type FieldError struct {
	Pointer string
	Code    string
	Detail  string
	// contains filtered or unexported fields
}

FieldError is a field of the Mention settings that is not valid, at a JSON pointer under /mentions, with a stable code of the validation-failed problem.

func (*FieldError) Error

func (e *FieldError) Error() string

type Mention

type Mention struct {
	Kind string `json:"kind"`
	Name string `json:"name"`
}

Mention is a Mention that names no one person: a group — a group entry or a Team mention — by its name, or everyone in the chat by its word; its Kind is TargetGroup or TargetEveryone. The zero Mention stands for a person.

type Mentioned

type Mentioned struct {
	UserID   int64
	PublicID string
	Mention  Mention
	Entry    EntryRef
	Event    string
}

Mentioned is a person — or, with Mention set, a group or everyone in the chat through a bridge — whom an entry named for the Loud event Event and whom the message mentions as their messenger mentions them; PublicID is the person's, as their target names them.

type OnCalls

type OnCalls interface {
	TeamOnCallAt(ctx context.Context, db DBTX, teamID int64, t time.Time) (int64, bool, error)
}

OnCalls is the On-call of a Team (C-27.FR-4), declared by its consumer; *schedules.Service implements it, and internal/runtime wires it. TeamOnCallAt is the User on Shift in the main Schedule of the Team teamID at t, by id, and false for a Team without a main Schedule or in a gap of it, read through db — the transaction of the resolution, so that it takes no second connection of the pool while the caller holds one — or the main pool for a nil one.

type Queries

type Queries interface {
	ListMentionEntries(ctx context.Context, arg dbgen.ListMentionEntriesParams) ([]dbgen.ListMentionEntriesRow, error)
	DeleteMentionEntries(ctx context.Context, arg dbgen.DeleteMentionEntriesParams) error
	InsertMentionEntries(ctx context.Context, arg dbgen.InsertMentionEntriesParams) error
	ResolveEntryUsers(ctx context.Context, arg dbgen.ResolveEntryUsersParams) ([]dbgen.ResolveEntryUsersRow, error)
	ResolveEntryTeams(ctx context.Context, arg dbgen.ResolveEntryTeamsParams) ([]dbgen.ResolveEntryTeamsRow, error)
	ListLiveTeams(ctx context.Context, orgID int64) ([]dbgen.ListLiveTeamsRow, error)
	GetMentionConnection(ctx context.Context, arg dbgen.GetMentionConnectionParams) (dbgen.GetMentionConnectionRow,
		error)
	ListAlertGroupTeams(ctx context.Context, arg dbgen.ListAlertGroupTeamsParams) ([]dbgen.ListAlertGroupTeamsRow,
		error)
	ListStormTeams(ctx context.Context, arg dbgen.ListStormTeamsParams) ([]dbgen.ListStormTeamsRow, error)
	LockEntryDestination(ctx context.Context, arg dbgen.LockEntryDestinationParams) (dbgen.LockEntryDestinationRow,
		error)
	BumpEntryDestination(ctx context.Context, arg dbgen.BumpEntryDestinationParams) error
	GetMentionEventAt(ctx context.Context, arg dbgen.GetMentionEventAtParams) (time.Time, error)
	GetPublicationEventAt(ctx context.Context, arg dbgen.GetPublicationEventAtParams) (time.Time, error)
	GetStormStartedAt(ctx context.Context, arg dbgen.GetStormStartedAtParams) (time.Time, error)
	GetEventOwners(ctx context.Context, arg dbgen.GetEventOwnersParams) (dbgen.GetEventOwnersRow, error)
	ListMentionUsers(ctx context.Context, arg dbgen.ListMentionUsersParams) ([]dbgen.ListMentionUsersRow, error)
	ListLiveUserPublicIDs(ctx context.Context, arg dbgen.ListLiveUserPublicIDsParams) ([]string, error)
	ListFooterUsers(ctx context.Context, arg dbgen.ListFooterUsersParams) ([]dbgen.ListFooterUsersRow, error)
	ListAssigneeUsers(ctx context.Context, arg dbgen.ListAssigneeUsersParams) ([]dbgen.ListAssigneeUsersRow, error)
}

Queries are the queries of the package.

type Request

type Request struct {
	DestinationID   int64
	DestinationType string
	ConnectionID    *int64
	AlertGroupID    int64
	StormID         int64
	Seq             int64
	At              time.Time
	Mentions        []string
}

Request is the Mentions of one Loud message to resolve: its Destination — id, type and Connection — its Alert Group, or for the first publication of a Storm summary its Storm, the lifecycle event it carries, 0 for none, the business time of the event, at which the On-call is taken — zero to have Resolve read it (eventAt) — and the symbolic Mentions.

type Resolution

type Resolution struct {
	Team     *TeamRef
	Mentions []Resolved
}

Resolution is what an entry mentions now for one Team, nil for the targets that name none.

type Resolved

type Resolved struct {
	Kind   string
	Name   string
	Linked bool
}

Resolved is one Mention an entry makes now: a user by the username of their Account link, else their login, with whether they have one; a group, a Team mention or a Team of an outgoing webhook by name; or the word of everyone.

type Result

type Result struct {
	Targets     []Target
	Undelivered []Undelivered
	Mentioned   []Mentioned
}

Result is the resolution of a Loud message's Mentions: its targets, in order, and for each person an entry named, once per person and entry, either Undelivered or Mentioned, and through a bridge the same for each group and everyone in the chat an entry named. An outgoing webhook, which takes every person as data, has neither.

func (Result) LeftOut

func (r Result) LeftOut(ids []string) Result

LeftOut is r once the delivered message left out the Mentions of the people whose public ids are ids for its length (C-12.FR-11): each Mentioned of theirs is Undelivered with message_too_long, after the Undelivered of r. r is left as it is.

func (Result) LeftOutMentions

func (r Result) LeftOutMentions(targets []Target) Result

LeftOutMentions is r once the delivered message left out for its length (C-12.FR-11) the Mentions of the groups and everyone in the chat among targets, a template's tokens included: each Mentioned of theirs is Undelivered with message_too_long, after the Undelivered of r, and then each of them that no entry named — a token's — once, without an entry. r is left as it is.

func (Result) Plain

func (r Result) Plain(ids []string) Result

Plain is r once the delivered message named the people whose public ids are ids by the plain name, without a marker, as a bridge does for an Account link whose marker it cannot build (C-22.FR-16): each Mentioned of theirs is Undelivered with bridge_cannot_mention_people, after the Undelivered of r. r is left as it is.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service validates Mention entries and settings, resolves Mentions and names users for the Organization.

func New

func New(orgID int64, db DBTX) *Service

New is the Service of the Organization orgID over the main pool db.

func (*Service) AssigneeUsers

func (s *Service) AssigneeUsers(ctx context.Context, db DBTX, groupID int64) (map[int64]map[string]User, error)

AssigneeUsers are the Assignees of the Alert Group groupID by id, each by the identity spaces where they have an Account link their messenger can mention them by, read through db, as FooterUsers reads the footer's user: item 7 of the Root message names them as Mentions there (C-29.FR-1, C-32.FR-12). An Assignee without such a link is not in it.

func (*Service) Entries

func (s *Service) Entries(ctx context.Context, db DBTX, ds []EntryDestination) (map[int64][]Entry, error)

Entries reads the Mention entries of the Destinations through db, or the main pool for a nil one, by Destination id, each with whether its Connection can mention it now and what it mentions now on the business clock (C-28.FR-1 to FR-3): the targets from the label for each Team that is not deleted. A Destination without entries has none.

func (*Service) FooterUsers added in v0.1.3

func (s *Service) FooterUsers(ctx context.Context, db DBTX, groupID int64) (map[string]User, error)

FooterUsers are the user the footer of the Alert Group groupID names — its Owner, who snoozed it or who resolved it — by the identity spaces where they have an Account link their messenger can mention them by, read through db, or the main pool for a nil one (C-12.FR-12): a Mattermost link with a username, a Telegram, Bridge or Slack link with the messenger's user id, which every link has. Each carries only what its adapter writes the user by, so that a Desired state changes only with what a messenger shows: the Muster display name, and a Mattermost link's username, a Telegram or Slack link's user id, a Bridge link's user id, display name and username, on one line. The adapter writes the user as its messenger's Mention (C-22.FR-16, C-24.FR-6); in any other identity space the footer names the User by their Muster display name.

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, db DBTX, org int64, r Request) (Result, error)

Resolve turns the symbolic Mentions of a Loud message into its targets in the Organization org, reading through db (C-28.FR-3, FR-4, FR-7): the Loud events among them into the Destination's entries that apply to any of them, in the entries' order — everyone with its word, a group by its name, a person by their Account link in the Destination's identity space and left out without one, a Team by its Team mention for the Connection and nobody without one, "Team from the label" by the Team mention of each Team of the Alert Group, the On-call of a Team by its main Schedule at the time of the request, nobody without one or in a gap, and the same for each Team of the Alert Group; for the first publication of a Storm summary the Teams of the Alert Groups the Storm counts. An entry that the Connection cannot mention now mentions nobody. An outgoing webhook takes every target as data, a person without an Account link and a Team as itself included (C-15.FR-11). The Owner turns into the Owner the lifecycle event recorded, or the Owner it released, and the previous Owner into the one a Takeover replaced, named as L1 named them, without a link by their display name. Each person and group is mentioned once. Each person an entry named that is not deleted is, once per entry, Undelivered — left out without an Account link, or named by the plain name through a bridge whose stored info does not declare native_mentions, or has none — or Mentioned, with the first of the message's Loud events the entry applies to. Through a bridge each group and everyone in the chat an entry named is Mentioned too, once per entry, so that a message whose Mention line leaves it out records it (LeftOutMentions).

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, destinationType string, set Settings, stored []EntryInput) error

Validate refuses Mention settings that a Destination of the type cannot take (C-12.FR-8, C-22.FR-3, C-24.FR-6): every kind is present; everyone is none, channel, all or here, only none for Telegram and Bridges, and not all for Slack; user_ids name Users that exist and are not deleted, or that an entry of stored, the Destination's entries before the save, names, so that a read sent back with a User deleted since is not refused for it (C-28.FR-5, settled 2); groups are Mattermost group names, and none for Telegram, Bridges and Slack. Outgoing webhooks take every choice, as data.

func (*Service) ValidateEntries

func (s *Service) ValidateEntries(ctx context.Context, c Check) ([]EntryInput, error)

ValidateEntries refuses Mention entries that the Destination cannot take and returns them in their canonical form, every event when an entry names none (C-28.FR-1, FR-2): each target of a kind with exactly its fields — the word of everyone, a User, a group's name with a Slack user group's id, required on Slack and refused on the others, or a Team — each target once; each event once; a target the Connection cannot mention now refused with mention_unsupported at /mention_entries/{i}/target, and a User or a Team that does not exist or is deleted with unknown_id at its field. An entry whose target equals a stored one is kept whatever its Connection can mention now and whether its User or Team was deleted since (C-28.FR-2, settled 2).

func (*Service) Wire

func (s *Service) Wire(onCalls OnCalls, teamMentions TeamMentions, business clock.Clock)

Wire gives the Service the On-call of the Teams, their Team mentions and the business clock, on which a read says what an entry mentions now and a request without a time takes the On-call; without them a Team and an On-call mention nobody.

func (*Service) WriteEntries

func (s *Service) WriteEntries(ctx context.Context, db DBTX, destinationID int64, entries []EntryInput,
	now time.Time) error

WriteEntries makes entries, validated, the Mention entries of the Destination destinationID, created now, through db — the transaction of the save — in their order; Users and Teams by public_id.

type Setting

type Setting struct {
	Everyone string   `json:"everyone"`
	UserIDs  []string `json:"user_ids"`
	Groups   []string `json:"groups"`
}

Setting is whom to mention for one kind of Loud event: everyone in the chat, chosen Users by public_id and messenger groups. The zero Setting mentions nobody (destination.mentions).

type Settings

type Settings map[string]Setting

Settings are the Mention settings of a Destination by kind (MentionSettings).

func L1Form

func L1Form(destinationType string, entries []EntryInput) Settings

L1Form is the Mention settings of L1 computed from the entries that L1 can express on the Destination type (C-28.FR-5): for each of its six kinds, the first everyone choice whose entry applies to it, the chosen Users and the groups, in the order of the entries. The other entries are not seen in it.

func Nobody

func Nobody() Settings

Nobody is the Mention settings of L1 that mention nobody (destination.mentions), which a Destination created from 0.2.0 on stores in its L1 column, so that a replica of 0.1 mentions nobody there (C-28.FR-5).

type Target

type Target struct {
	Kind     string      `json:"kind"`
	Everyone string      `json:"everyone,omitempty"`
	Group    string      `json:"group,omitempty"`
	GroupID  string      `json:"group_id,omitempty"`
	User     *User       `json:"user,omitempty"`
	Team     *TeamTarget `json:"team,omitempty"`
}

Target is one Mention for an adapter to render: everyone in the chat with the word — the symbolic name a Bridge receives — a messenger group — a Team mention among them — by its name with a Slack user group's id, which the Slack adapter writes as <!subteam^id> and a Bridge names by the group's name, a User, or for an outgoing webhook a Team as data (C-15.FR-11, C-22.FR-16, C-24.FR-6).

type TeamEntry

type TeamEntry struct {
	PublicID string
	Name     string
	Before   []EntryInput
	After    []EntryInput
}

TeamEntry is the entry "Team {Team}" that a Team added to one of its Destinations (C-28.FR-6): the Destination by public_id, name and new version, and its entries before and after, for the Audit log diff of destination.updated.

func AddTeamEntry

func AddTeamEntry(ctx context.Context, db DBTX, org, destinationID, teamID int64, teamPublicID string,
	now time.Time) (TeamEntry, bool, error)

AddTeamEntry adds the entry "Team {Team}" for every Loud event to the Destination destinationID that the Team teamID (public_id teamPublicID) of the Organization org names as a Destination of the Team, through db — the transaction of the Team's save — after its other entries, created now, and gives the Destination a new version (C-28.FR-6, C-26.FR-1). It adds nothing and returns false to a Destination that already has an entry of the kind team with that Team, to a Telegram Destination, which cannot mention Teams (settled 1), to a deleted one, and to one that has MaxEntries entries. The Destination's row is locked after the Team's, the order of a save of the Destination with an owning Team.

type TeamMention

type TeamMention struct {
	Group   string
	GroupID string
}

TeamMention is the Team mention that mentions a Team through a Connection (C-25.FR-8): the group and, for a Slack Connection, the user group's id.

type TeamMentions

type TeamMentions interface {
	ForConnection(ctx context.Context, db DBTX, teamID, connectionID int64) (TeamMention, bool, error)
}

TeamMentions are the Team mentions of the Teams (C-25.FR-8), declared by their consumer; *teams.Service implements them, and internal/runtime wires them. ForConnection is the Team mention of the Team teamID for the Connection connectionID, false when there is none that the Connection can carry now, read through db as OnCalls reads.

type TeamRef

type TeamRef struct {
	ID       int64
	PublicID string
	Name     string
	Slug     string
	Deleted  bool
}

TeamRef is a Team an entry names or resolves for, marked deleted once deleted.

type TeamTarget

type TeamTarget struct {
	Slug string `json:"slug"`
	Name string `json:"name"`
}

TeamTarget is a Team as an outgoing webhook receives it: its slug and name.

type Undelivered

type Undelivered struct {
	UserID  int64
	Mention Mention
	Entry   EntryRef
	Event   string
	Reason  string
}

Undelivered is a person — or, with Mention set, a group or everyone in the chat — whom an entry named for the Loud event Event and whom the message does not mention as their messenger mentions them, with the reason (C-28.FR-3). A template's token that a bridge's message left out has a Mention and neither an entry nor an event (C-12.FR-11).

type User

type User struct {
	PublicID    string `json:"id"`
	Name        string `json:"name"`
	Login       string `json:"login"`
	Username    string `json:"username,omitempty"`
	ExternalID  string `json:"external_id,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
}

User is a User as a Mention names them: public_id, display name, login, and the username, the messenger's user id and the display name of their Account link in the Destination's identity space, empty without one; Telegram mentions a user by that id (C-12.FR-8), a Bridge by that id and the link's display name (C-22.FR-16), and Slack by that id (C-24.FR-6).

func (User) Display

func (u User) Display() string

Display is how the User is shown: the messenger username of their Account link, otherwise the display name as plain text, which notifies nobody (C-12.FR-12).

type UserRef

type UserRef struct {
	ID       int64
	PublicID string
	Name     string
	Login    string
	Deleted  bool
}

UserRef is the User an entry names, by id and public_id, marked deleted once deleted.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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