Documentation
¶
Index ¶
- Variables
- func CheckFileChannelRead(mm Client, userID string, fileInfo *model.FileInfo) error
- func GetReadableFileInfo(mm Client, sessionID, userID, fileID string) (*model.FileInfo, error)
- func IsDMWith(userID string, channel *model.Channel) bool
- func IsKVNotFound(err error) bool
- func IsNotFound(err error) bool
- type Client
- type DBClient
- type FileActionPermissionAPI
- type ThreadData
Constants ¶
This section is empty.
Variables ¶
var ErrFileActionForbidden = errors.New("file action is not permitted")
ErrFileActionForbidden is returned before an admin-level file read when the requesting session is absent or denied by the server's file policy.
var ErrFileChannelForbidden = errors.New("user cannot read the channel the file belongs to")
ErrFileChannelForbidden is returned when a user can no longer read the channel a stored file belongs to.
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 CheckFileChannelRead ¶ added in v2.12.0
CheckFileChannelRead fails closed unless userID may read the channel fileInfo belongs to. Download policy is a separate, session-scoped check (see WithFilePolicy); both must pass before stored file content is reused.
func GetReadableFileInfo ¶ added in v2.12.0
GetReadableFileInfo returns fileID's metadata only when sessionID may download the file and userID may still read its channel.
func IsKVNotFound ¶
func IsNotFound ¶ added in v2.11.0
IsNotFound reports whether err says the requested Mattermost object does not exist, as opposed to failing to look it up.
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]any, broadcast *model.WebsocketBroadcast)
GetConfig() *model.Config
LogError(msg string, keyValuePairs ...any)
LogWarn(msg string, keyValuePairs ...any)
KVGet(key string, value any) error
KVSet(key string, value any) error
KVSetWithExpiry(key string, value any, ttl time.Duration) error
KVCompareAndSet(key string, oldValue, newValue any) (bool, error)
KVCompareAndSetWithExpiry(key string, oldValue, newValue any, ttl time.Duration) (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 ...any)
GetChannelByName(teamID, name string, includeDeleted bool) (*model.Channel, error)
HasPermissionToChannel(userID, channelID string, permission *model.Permission) bool
HasPermissionToFileAction(sessionID, fileID, action string) bool
GetFileInfo(fileID string) (*model.FileInfo, error)
GetFile(fileID string) (io.ReadCloser, error)
UploadFile(content io.Reader, fileName, channelID string) (*model.FileInfo, error)
SendEphemeralPost(userID string, post *model.Post)
}
func NewClient ¶
func NewClient(pluginAPI *pluginapi.Client, fileActionAPI ...FileActionPermissionAPI) Client
func WithFilePolicy ¶ added in v2.5.4
WithFilePolicy returns a Client whose GetFile and GetFileInfo calls are gated by the requesting session's download-file policy. Other methods delegate unchanged. An empty or denied session fails closed.
type DBClient ¶
func NewDBClient ¶
NewDBClient creates the DB part of the client, only supported on postgres, panics on failures.
func NewTestDBClient ¶
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
type FileActionPermissionAPI ¶ added in v2.5.4
type FileActionPermissionAPI interface {
HasPermissionToFileAction(sessionID, fileID, action string) bool
}
FileActionPermissionAPI is the narrow raw plugin API surface needed to enforce session-scoped file download policy.
type ThreadData ¶
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)