Documentation
¶
Overview ¶
Package chat is the notify adapters for chat platforms that take an incoming webhook: Slack, Microsoft Teams and Discord (R-374, issue #50).
Each posts to one channel, named by a webhook URL an administrator creates in the platform, so each is a channel adapter: it ignores recipients, and only event subscriptions send to it (R-373). A message meant for one person never lands in a room.
The webhook URL is the credential. Whoever holds it can post to the channel, so it is stored sealed like any adapter credential and never shown again (R-190).
Index ¶
- Variables
- type Adapter
- func (a *Adapter) Capabilities() api.NotifyCapabilities
- func (a *Adapter) Category() api.Category
- func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error
- func (a *Adapter) HealthCheck(context.Context) error
- func (a *Adapter) Kind() string
- func (a *Adapter) Notify(ctx context.Context, n api.Notification) error
- type Config
- type Credentials
- type Platform
Constants ¶
This section is empty.
Variables ¶
var Discord = Platform{ Kind: "discord", Name: "Discord", Description: "Posts the events a subscription chooses to a Discord channel, through a channel webhook.", IDPrefix: "ntf_", Placeholder: "https://discord.com/api/webhooks/…", Help: "The webhook URL from the Discord channel's Integrations settings.", Hosts: []string{"discord.com", "discordapp.com"}, Format: discordMessage, }
Discord posts to a Discord channel webhook.
var Slack = Platform{ Kind: "slack", Name: "Slack", Description: "Posts the events a subscription chooses to a Slack channel, through an incoming webhook.", IDPrefix: "ntf_", Placeholder: "https://hooks.slack.com/services/…", Help: "The incoming webhook URL Slack gives you for the channel.", Hosts: []string{"hooks.slack.com", "hooks.slack-gov.com"}, Format: slackMessage, }
Slack posts to a Slack incoming webhook.
var Teams = Platform{
Kind: "teams",
Name: "Microsoft Teams",
Description: "Posts the events a subscription chooses to a Microsoft Teams channel, as an adaptive card, through a Workflows webhook.",
IDPrefix: "ntf_",
Placeholder: "https://….logic.azure.com/workflows/…",
Help: "The URL of a Teams workflow that posts a webhook's adaptive card to the channel.",
Format: teamsMessage,
}
Teams posts to a Microsoft Teams channel through a Workflows webhook.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter posts to one channel.
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() api.NotifyCapabilities
Capabilities: a channel, not people.
func (*Adapter) HealthCheck ¶
HealthCheck succeeds once configured. It does not post: a health check that sends a message to a channel every five minutes would be the outage.
type Config ¶
type Config struct {
Credentials Credentials `json:"credentials,omitzero"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
}
Config is the adapter's configuration.
type Credentials ¶
Credentials is what this adapter keeps secret.
type Platform ¶
type Platform struct {
Kind string
Name string
Description string
IDPrefix string
Placeholder string
Help string
// Hosts are the hosts a webhook URL for the platform is on. A URL on
// another host is refused at configuration, because a webhook URL pasted
// into the wrong platform's form fails at the first event otherwise.
// Empty accepts any host.
Hosts []string
Format func(n api.Notification) any
}
Platform is what differs between the three: a name, and how a notification is laid out.