mmapi

package
v0.0.1-rc99 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKVNotFound = errors.New("kv key not found")

ErrKVNotFound disambiguates a missing key from a present-but-zero value: upstream pluginapi.KV.Get returns (nil err, empty bytes) for missing keys.

Functions

func IsDMWith

func IsDMWith(userID string, channel *model.Channel) bool

func IsKVNotFound

func IsKVNotFound(err error) bool

Types

type Client

type Client interface {
	GetUser(userID string) (*model.User, error)
	GetPost(postID string) (*model.Post, error)
	AddReaction(*model.Reaction) error
	GetPostThread(postID string) (*model.PostList, error)
	GetPostsSince(channelID string, since int64) (*model.PostList, error)
	GetPostsBefore(channelID, postID string, page, perPage int) (*model.PostList, error)
	CreatePost(post *model.Post) error
	UpdatePost(post *model.Post) error
	DM(senderID, receiverID string, post *model.Post) error
	GetTeam(teamID string) (*model.Team, error)
	GetChannel(channelID string) (*model.Channel, error)
	GetDirectChannel(userID1, userID2 string) (*model.Channel, error)
	PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
	GetConfig() *model.Config
	LogError(msg string, keyValuePairs ...interface{})
	LogWarn(msg string, keyValuePairs ...interface{})
	KVGet(key string, value interface{}) error
	KVSet(key string, value interface{}) error
	KVSetWithExpiry(key string, value interface{}, ttl time.Duration) error
	KVCompareAndSet(key string, oldValue, newValue interface{}) (bool, error)
	KVDelete(key string) error
	GetUserByUsername(username string) (*model.User, error)
	GetUserStatus(userID string) (*model.Status, error)
	HasPermissionTo(userID string, permission *model.Permission) bool
	GetPluginStatus(pluginID string) (*model.PluginStatus, error)
	PluginHTTP(req *http.Request) *http.Response
	LogDebug(msg string, keyValuePairs ...interface{})
	GetChannelByName(teamID, name string, includeDeleted bool) (*model.Channel, error)
	HasPermissionToChannel(userID, channelID string, permission *model.Permission) bool
	GetFileInfo(fileID string) (*model.FileInfo, error)
	GetFile(fileID string) (io.ReadCloser, error)
	SendEphemeralPost(userID string, post *model.Post)
}

func NewClient

func NewClient(pluginAPI *pluginapi.Client) Client

type DBClient

type DBClient struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func NewDBClient

func NewDBClient(pluginAPI *pluginapi.Client) *DBClient

NewDBClient creates the DB part of the client, only supported on postgres, panics on failures.

func NewTestDBClient

func NewTestDBClient(db *sqlx.DB) *DBClient

NewTestDBClient creates a DBClient for testing purposes using a raw sqlx.DB connection. This bypasses the plugin API requirement for test environments.

func (*DBClient) Builder

func (db *DBClient) Builder() sq.StatementBuilderType

func (*DBClient) DoQuery

func (db *DBClient) DoQuery(dest any, b builder) error

func (*DBClient) ExecBuilder

func (db *DBClient) ExecBuilder(b builder) (sql.Result, error)

func (*DBClient) GetFirstPostBeforeTimeRangeID

func (c *DBClient) GetFirstPostBeforeTimeRangeID(channelID string, startTime, endTime int64) (string, error)

type ThreadData

type ThreadData struct {
	Posts     []*model.Post
	UsersByID map[string]*model.User
}

func GetMetadataForPosts

func GetMetadataForPosts(client Client, posts *model.PostList) (*ThreadData, error)

func GetThreadData

func GetThreadData(client Client, postID string) (*ThreadData, error)

func (*ThreadData) CutoffBeforePostID

func (t *ThreadData) CutoffBeforePostID(postID string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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