Documentation
¶
Overview ¶
Package mm is a thin Mattermost REST client covering only the endpoints mmcli needs: login, fetch post/thread, search, create post, and resolve teams/channels/users. It is intentionally not the official SDK.
Index ¶
- type Channel
- type Client
- func (c *Client) CreatePost(ctx context.Context, channelID, message, rootID string) (*Post, error)
- func (c *Client) DeletePost(ctx context.Context, id string) error
- func (c *Client) GetChannelByName(ctx context.Context, teamID, name string) (*Channel, error)
- func (c *Client) GetPost(ctx context.Context, id string) (*Post, error)
- func (c *Client) GetTeamByName(ctx context.Context, name string) (*Team, error)
- func (c *Client) GetThread(ctx context.Context, id string) (*PostList, error)
- func (c *Client) Login(ctx context.Context) error
- func (c *Client) Search(ctx context.Context, teamID string, opts SearchOpts) (*PostList, error)
- func (c *Client) UsersByIDs(ctx context.Context, ids []string) ([]User, error)
- type Post
- type PostList
- type SearchOpts
- type Team
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct {
ID string `json:"id"`
TeamID string `json:"team_id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
}
Channel is a Mattermost channel (subset).
type Client ¶
type Client struct {
// OnToken, if set, is called whenever a new session token is obtained.
OnToken func(token string)
// contains filtered or unexported fields
}
Client talks to one Mattermost server. It is stateless across processes: a session token is cached by the caller (in the keyring) and passed back in. On a 401 the client re-logs-in once using loginID/password, then retries, and reports the fresh token via OnToken.
func (*Client) CreatePost ¶
CreatePost posts a message to a channel. rootID, if non-empty, makes it a threaded reply.
func (*Client) DeletePost ¶
DeletePost deletes a post by ID.
func (*Client) GetChannelByName ¶
GetChannelByName resolves a channel by name within a team.
func (*Client) GetTeamByName ¶
GetTeamByName resolves a team by its URL name.
type Post ¶
type Post struct {
ID string `json:"id"`
CreateAt int64 `json:"create_at"`
UpdateAt int64 `json:"update_at"`
UserID string `json:"user_id"`
ChannelID string `json:"channel_id"`
RootID string `json:"root_id"`
Message string `json:"message"`
}
Post is a single Mattermost post (subset of fields we use).
type PostList ¶
PostList is Mattermost's ordered post collection (threads, search results). Order lists post IDs newest-first; Posts maps ID -> Post.
type SearchOpts ¶
type SearchOpts struct {
Terms string `json:"terms"`
IsOrSearch bool `json:"is_or_search"`
Page int `json:"page"`
PerPage int `json:"per_page"`
}
SearchOpts mirrors the Mattermost search request body fields we use.