mattermost

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMattermostApp

func NewMattermostApp(conf *Config) *common.BaseApp

Types

type Attachment

type Attachment struct {
	ID      int64        `json:"id"`
	Text    string       `json:"text"`
	Actions []PostAction `json:"actions,omitempty"`
}

type Bot

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

Bot is a Mattermost client that works with access.Request.

func NewBot

func NewBot(conf Config, clusterName, webProxyAddr string) (Bot, error)

func (Bot) BroadcastAccessRequestMessage

func (b Bot) BroadcastAccessRequestMessage(ctx context.Context, recipients []common.Recipient, reqID string, reqData pd.AccessRequestData) (accessrequest.SentMessages, error)

BroadcastAccessRequestMessage posts request info to Mattermost.

func (Bot) CheckHealth

func (b Bot) CheckHealth(ctx context.Context) error

func (Bot) FetchRecipient

func (b Bot) FetchRecipient(ctx context.Context, name string) (*common.Recipient, error)

FetchRecipient returns the recipient for the given raw recipient.

func (Bot) GetMe

func (b Bot) GetMe(ctx context.Context) (User, error)

func (Bot) LookupChannel

func (b Bot) LookupChannel(ctx context.Context, team, name string) (string, error)

LookupChannel fetches channel id by its name and team name.

func (Bot) LookupDirectChannel

func (b Bot) LookupDirectChannel(ctx context.Context, email string) (string, error)

LookupDirectChannel fetches user's direct message channel id by email.

func (Bot) PostReviewReply

func (b Bot) PostReviewReply(ctx context.Context, channelID, rootID string, review types.AccessReview) error

func (Bot) SendReviewReminders

func (b Bot) SendReviewReminders(ctx context.Context, recipients []common.Recipient, accessList *accesslist.AccessList) error

SendReviewReminders will send a review reminder that an access list needs to be reviewed.

func (Bot) SupportedApps

func (b Bot) SupportedApps() []common.App

SupportedApps are the apps supported by this bot.

func (Bot) UpdateMessages

func (b Bot) UpdateMessages(ctx context.Context, reqID string, reqData pd.AccessRequestData, mmData accessrequest.SentMessages, reviews []types.AccessReview) error

type Channel

type Channel struct {
	ID     string `json:"id"`
	TeamID string `json:"team_id"`
	Type   string `json:"type"`
	Name   string `json:"name"`
}

type Config

type Config struct {
	common.BaseConfig
	Mattermost MattermostConfig `toml:"mattermost"`
	StatusSink common.StatusSink
}

func LoadConfig

func LoadConfig(filepath string) (*Config, error)

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

func (*Config) NewBot

func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot, error)

type ErrorResult

type ErrorResult struct {
	ID            string `json:"id"`
	Message       string `json:"message"`
	DetailedError string `json:"detailed_error"`
	RequestID     string `json:"request_id"`
	StatusCode    int    `json:"status_code"`
}

func (ErrorResult) Error

func (e ErrorResult) Error() string

type MattermostConfig

type MattermostConfig struct {
	URL        string   `toml:"url"`
	Recipients []string `toml:"recipients"` // optional
	Token      string   `toml:"token"`
}

type Post

type Post struct {
	ID        string `json:"id,omitempty"`
	ChannelID string `json:"channel_id"`
	Message   string `json:"message"`
	RootID    string `json:"root_id"`
	Props     Props  `json:"props"`
}

func (Post) Attachments

func (post Post) Attachments() []Attachment

type PostAction

type PostAction struct {
	ID          string                 `json:"id,omitempty"`
	Name        string                 `json:"name,omitempty"`
	Integration *PostActionIntegration `json:"integration,omitempty"`
}

type PostActionIntegration

type PostActionIntegration struct {
	URL     string                 `json:"url,omitempty"`
	Context map[string]interface{} `json:"context,omitempty"`
}

type Props

type Props map[string]interface{}

type Team

type Team struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type User

type User struct {
	ID        string `json:"id"`
	Username  string `json:"username"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
}

Jump to

Keyboard shortcuts

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