mentions

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 13 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 the Mention settings of C-12.FR-8 and FR-12: whom a Destination mentions for each kind of Loud event — nobody, everyone in the chat with the word its messenger offers, chosen Users or messenger groups — validated per Destination type, Telegram and Bridges taking nobody and chosen Users only (C-22.FR-3), Slack no Mention of all and no messenger groups (C-24.FR-6), and the resolution of a Loud message's symbolic Mentions into targets: the Destination's setting for a kind, the Owner the lifecycle event recorded, or its previous Owner. 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 users the same way, a Bridge or a Slack link by its display name. Storing the settings is the Destination's, and rendering a target in a messenger's syntax is its adapter's.

Index

Constants

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.

Variables

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

Functions

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.

Types

type DBTX

type DBTX = dbgen.DBTX

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

type FieldError

type FieldError struct {
	Pointer string
	Code    string
	Detail  string
}

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 Queries

type Queries interface {
	GetDestinationMentions(ctx context.Context, arg dbgen.GetDestinationMentionsParams) ([]byte, 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)
	ListFooterUsernames(ctx context.Context, arg dbgen.ListFooterUsernamesParams) ([]dbgen.ListFooterUsernamesRow,
		error)
}

Queries are the queries of the package.

type Request

type Request struct {
	DestinationID   int64
	DestinationType string
	ConnectionID    *int64
	AlertGroupID    int64
	Seq             int64
	Mentions        []string
}

Request is the Mentions of one Loud message to resolve: its Destination — id, type and Connection — its Alert Group and the lifecycle event it carries, 0 for none, and the symbolic Mentions.

type Service

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

Service validates Mention 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) FooterNames

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

FooterNames are the names, by identity space, of the user the footer of the Alert Group groupID names — its Owner, who snoozed it or who resolved it — read through db, or the main pool for a nil one (C-12.FR-12): the username of a Mattermost or Telegram link, the display name of a Bridge link, else its username (C-22.FR-16), and the display name of a Slack link (C-24.FR-6), each on one line; a link whose name is blank is left out, so that 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) ([]Target, error)

Resolve turns the symbolic Mentions of a Loud message into its targets in the Organization org, reading through db (C-12.FR-8): a kind of Loud event into the Destination's setting for it — everyone, its groups, its Users — the Owner into the Owner the lifecycle event recorded, or the Owner it released, and the previous Owner into the one a Takeover replaced. A Reopen into acknowledged carries only the Owner, by the lifecycle event table. Duplicates are left out, and so are the choices the Destination's type does not offer.

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, destinationType string, set Settings) 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; groups are Mattermost group names, and none for Telegram, Bridges and Slack. Outgoing webhooks take every choice, as data.

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).

type Target

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

Target is one Mention for an adapter to render: everyone in the chat with the word, a messenger group, or a User.

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).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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