mattermost

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mattermost is the gateway's Mattermost channel adapter, aimed at self-hosted servers. It listens on the server's WebSocket event stream (api/v4/websocket) for new posts and replies over the REST v4 API — no SDK, just net/http plus gorilla/websocket for the socket (the dependency is isolated here, guarded by TestVendorSDKsOnlyInTheirAdapters). The user creates a bot account, generates a bot access token, and puts the server base URL and token in the global .env as MATTERMOST_URL (e.g. https://mm.example.com) and MATTERMOST_TOKEN; messages and the token never leave the machines the user already runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

Channel is a Mattermost bot connection.

func New

func New(serverURL, token, mediaDir string) *Channel

New builds a Mattermost channel for the given server base URL and bot access token. mediaDir is the gateway media spool file attachments are downloaded into; "" disables attachment handling (messages still flow as text).

func (*Channel) Name

func (c *Channel) Name() string

Name returns the adapter identifier.

func (*Channel) Send

func (c *Channel) Send(ctx context.Context, conversation string, msg channels.Outbound) error

Send posts a reply to a channel, split with the shared chunker to stay under Mattermost's per-post length cap. A non-2xx fails fast rather than retrying.

func (*Channel) Start

func (c *Channel) Start(ctx context.Context, sink channels.Sink) error

Start connects to the websocket event stream and forwards each user post as an Inbound until ctx is cancelled. A dropped socket reconnects with jittered exponential backoff rather than returning (each failure logged, never swallowed), so a flaky server never takes the gateway down. A permanently bad MATTERMOST_URL (unparseable, or not http/https) IS fatal: retrying can never fix config, so the error is returned and the gateway reports the channel as stopped instead of silently spinning forever.

Jump to

Keyboard shortcuts

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