2017-10-25 11:33:19 -05:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
2017-08-16 17:23:38 -05:00
|
|
|
package plugin
|
|
|
|
|
|
2017-08-28 14:19:00 -05:00
|
|
|
import (
|
2018-11-19 15:27:17 -05:00
|
|
|
plugin "github.com/hashicorp/go-plugin"
|
2017-09-06 23:05:10 -07:00
|
|
|
"github.com/mattermost/mattermost-server/model"
|
2017-08-28 14:19:00 -05:00
|
|
|
)
|
|
|
|
|
|
2017-11-03 11:34:44 -05:00
|
|
|
// The API can be used to retrieve data or perform actions on behalf of the plugin. Most methods
|
|
|
|
|
// have direct counterparts in the REST API and very similar behavior.
|
|
|
|
|
//
|
2018-07-13 10:29:50 -04:00
|
|
|
// Plugins obtain access to the API by embedding MattermostPlugin and accessing the API member
|
|
|
|
|
// directly.
|
2017-08-16 17:23:38 -05:00
|
|
|
type API interface {
|
|
|
|
|
// LoadPluginConfiguration loads the plugin's configuration. dest should be a pointer to a
|
|
|
|
|
// struct that the configuration JSON can be unmarshalled to.
|
|
|
|
|
LoadPluginConfiguration(dest interface{}) error
|
2017-08-28 14:19:00 -05:00
|
|
|
|
2017-12-08 13:55:41 -06:00
|
|
|
// RegisterCommand registers a custom slash command. When the command is triggered, your plugin
|
|
|
|
|
// can fulfill it via the ExecuteCommand hook.
|
|
|
|
|
RegisterCommand(command *model.Command) error
|
|
|
|
|
|
|
|
|
|
// UnregisterCommand unregisters a command previously registered via RegisterCommand.
|
|
|
|
|
UnregisterCommand(teamId, trigger string) error
|
|
|
|
|
|
2018-08-02 00:16:04 +02:00
|
|
|
// GetSession returns the session object for the Session ID
|
|
|
|
|
GetSession(sessionId string) (*model.Session, *model.AppError)
|
|
|
|
|
|
2018-07-07 00:32:55 +02:00
|
|
|
// GetConfig fetches the currently persisted config
|
|
|
|
|
GetConfig() *model.Config
|
|
|
|
|
|
|
|
|
|
// SaveConfig sets the given config and persists the changes
|
|
|
|
|
SaveConfig(config *model.Config) *model.AppError
|
|
|
|
|
|
2018-11-19 22:57:15 +05:30
|
|
|
// GetPluginConfig fetches the currently persisted config of plugin
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetPluginConfig() map[string]interface{}
|
|
|
|
|
|
|
|
|
|
// SavePluginConfig sets the given config for plugin and persists the changes
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
SavePluginConfig(config map[string]interface{}) *model.AppError
|
|
|
|
|
|
2018-09-27 18:56:47 +02:00
|
|
|
// GetServerVersion return the current Mattermost server version
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.4
|
2018-09-27 18:56:47 +02:00
|
|
|
GetServerVersion() string
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// CreateUser creates a user.
|
|
|
|
|
CreateUser(user *model.User) (*model.User, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// DeleteUser deletes a user.
|
|
|
|
|
DeleteUser(userId string) *model.AppError
|
|
|
|
|
|
2019-01-30 18:55:02 +01:00
|
|
|
// GetUsers a list of users based on search options.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
GetUsers(*model.UserGetOptions) ([]*model.User, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// GetUser gets a user.
|
|
|
|
|
GetUser(userId string) (*model.User, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// GetUserByEmail gets a user by their email address.
|
|
|
|
|
GetUserByEmail(email string) (*model.User, *model.AppError)
|
2017-08-28 14:19:00 -05:00
|
|
|
|
|
|
|
|
// GetUserByUsername gets a user by their username.
|
|
|
|
|
GetUserByUsername(name string) (*model.User, *model.AppError)
|
|
|
|
|
|
2018-10-18 15:11:30 +02:00
|
|
|
// GetUsersByUsernames gets users by their usernames.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetUsersByUsernames(usernames []string) ([]*model.User, *model.AppError)
|
|
|
|
|
|
2018-10-15 18:24:26 +02:00
|
|
|
// GetUsersInTeam gets users in team.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-15 18:24:26 +02:00
|
|
|
GetUsersInTeam(teamId string, page int, perPage int) ([]*model.User, *model.AppError)
|
2018-11-16 14:17:42 +01:00
|
|
|
|
2018-11-20 15:43:42 +01:00
|
|
|
// GetTeamIcon gets the team icon.
|
2018-11-16 14:17:42 +01:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetTeamIcon(teamId string) ([]byte, *model.AppError)
|
2018-10-15 18:24:26 +02:00
|
|
|
|
2018-11-20 15:43:42 +01:00
|
|
|
// SetTeamIcon sets the team icon.
|
2018-11-16 16:52:07 +01:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
SetTeamIcon(teamId string, data []byte) *model.AppError
|
|
|
|
|
|
2018-11-20 15:43:42 +01:00
|
|
|
// RemoveTeamIcon removes the team icon.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
RemoveTeamIcon(teamId string) *model.AppError
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// UpdateUser updates a user.
|
|
|
|
|
UpdateUser(user *model.User) (*model.User, *model.AppError)
|
|
|
|
|
|
2018-07-16 15:49:26 -04:00
|
|
|
// GetUserStatus will get a user's status.
|
|
|
|
|
GetUserStatus(userId string) (*model.Status, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// GetUserStatusesByIds will return a list of user statuses based on the provided slice of user IDs.
|
|
|
|
|
GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// UpdateUserStatus will set a user's status until the user, or another integration/plugin, sets it back to online.
|
|
|
|
|
// The status parameter can be: "online", "away", "dnd", or "offline".
|
|
|
|
|
UpdateUserStatus(userId, status string) (*model.Status, *model.AppError)
|
|
|
|
|
|
2018-12-12 09:18:41 -06:00
|
|
|
// UpdateUserActive deactivates or reactivates an user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.8
|
|
|
|
|
UpdateUserActive(userId string, active bool) *model.AppError
|
|
|
|
|
|
2018-10-22 08:49:50 -04:00
|
|
|
// GetUsersInChannel returns a page of users in a channel. Page counting starts at 0.
|
|
|
|
|
// The sortBy parameter can be: "username" or "status".
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetUsersInChannel(channelId, sortBy string, page, perPage int) ([]*model.User, *model.AppError)
|
|
|
|
|
|
2018-08-29 14:07:27 -04:00
|
|
|
// GetLDAPUserAttributes will return LDAP attributes for a user.
|
|
|
|
|
// The attributes parameter should be a list of attributes to pull.
|
|
|
|
|
// Returns a map with attribute names as keys and the user's attributes as values.
|
|
|
|
|
// Requires an enterprise license, LDAP to be configured and for the user to use LDAP as an authentication method.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-29 14:07:27 -04:00
|
|
|
GetLDAPUserAttributes(userId string, attributes []string) (map[string]string, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// CreateTeam creates a team.
|
|
|
|
|
CreateTeam(team *model.Team) (*model.Team, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// DeleteTeam deletes a team.
|
|
|
|
|
DeleteTeam(teamId string) *model.AppError
|
|
|
|
|
|
2018-07-07 00:32:55 +02:00
|
|
|
// GetTeam gets all teams.
|
|
|
|
|
GetTeams() ([]*model.Team, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// GetTeam gets a team.
|
|
|
|
|
GetTeam(teamId string) (*model.Team, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// GetTeamByName gets a team by its name.
|
|
|
|
|
GetTeamByName(name string) (*model.Team, *model.AppError)
|
|
|
|
|
|
2018-11-07 20:23:02 +01:00
|
|
|
// GetTeamsUnreadForUser gets the unread message and mention counts for each team to which the given user belongs.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetTeamsUnreadForUser(userId string) ([]*model.TeamUnread, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// UpdateTeam updates a team.
|
|
|
|
|
UpdateTeam(team *model.Team) (*model.Team, *model.AppError)
|
|
|
|
|
|
2019-01-16 15:13:15 +07:00
|
|
|
// SearchTeams search a team.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.8
|
|
|
|
|
SearchTeams(term string) ([]*model.Team, *model.AppError)
|
|
|
|
|
|
2018-10-17 16:37:52 +02:00
|
|
|
// GetTeamsForUser returns list of teams of given user ID.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetTeamsForUser(userId string) ([]*model.Team, *model.AppError)
|
|
|
|
|
|
2018-07-07 00:32:55 +02:00
|
|
|
// CreateTeamMember creates a team membership.
|
|
|
|
|
CreateTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// CreateTeamMember creates a team membership for all provided user ids.
|
|
|
|
|
CreateTeamMembers(teamId string, userIds []string, requestorId string) ([]*model.TeamMember, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// DeleteTeamMember deletes a team membership.
|
|
|
|
|
DeleteTeamMember(teamId, userId, requestorId string) *model.AppError
|
|
|
|
|
|
|
|
|
|
// GetTeamMembers returns the memberships of a specific team.
|
2018-11-19 14:43:49 +01:00
|
|
|
GetTeamMembers(teamId string, page, perPage int) ([]*model.TeamMember, *model.AppError)
|
2018-07-07 00:32:55 +02:00
|
|
|
|
|
|
|
|
// GetTeamMember returns a specific membership.
|
|
|
|
|
GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
|
|
|
|
|
|
2019-02-23 11:41:19 -08:00
|
|
|
// GetTeamMembersForUser returns all team memberships for a user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
GetTeamMembersForUser(userId string, page int, perPage int) ([]*model.TeamMember, *model.AppError)
|
|
|
|
|
|
2018-07-07 00:32:55 +02:00
|
|
|
// UpdateTeamMemberRoles updates the role for a team membership.
|
|
|
|
|
UpdateTeamMemberRoles(teamId, userId, newRoles string) (*model.TeamMember, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// CreateChannel creates a channel.
|
|
|
|
|
CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// DeleteChannel deletes a channel.
|
|
|
|
|
DeleteChannel(channelId string) *model.AppError
|
|
|
|
|
|
2018-07-20 12:03:08 -04:00
|
|
|
// GetPublicChannelsForTeam gets a list of all channels.
|
2018-11-19 14:43:49 +01:00
|
|
|
GetPublicChannelsForTeam(teamId string, page, perPage int) ([]*model.Channel, *model.AppError)
|
2018-07-07 00:32:55 +02:00
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// GetChannel gets a channel.
|
|
|
|
|
GetChannel(channelId string) (*model.Channel, *model.AppError)
|
|
|
|
|
|
2018-07-20 12:03:08 -04:00
|
|
|
// GetChannelByName gets a channel by its name, given a team id.
|
2018-07-30 15:06:08 -04:00
|
|
|
GetChannelByName(teamId, name string, includeDeleted bool) (*model.Channel, *model.AppError)
|
2018-07-20 12:03:08 -04:00
|
|
|
|
|
|
|
|
// GetChannelByNameForTeamName gets a channel by its name, given a team name.
|
2018-07-30 15:06:08 -04:00
|
|
|
GetChannelByNameForTeamName(teamName, channelName string, includeDeleted bool) (*model.Channel, *model.AppError)
|
2017-08-28 14:19:00 -05:00
|
|
|
|
2018-10-15 18:27:45 +02:00
|
|
|
// GetChannelsForTeamForUser gets a list of channels for given user ID in given team ID.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-11-20 14:50:34 +01:00
|
|
|
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError)
|
2018-10-15 18:27:45 +02:00
|
|
|
|
2018-10-25 17:24:43 +00:00
|
|
|
// GetChannelStats gets statistics for a channel.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetChannelStats(channelId string) (*model.ChannelStats, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// GetDirectChannel gets a direct message channel.
|
2018-11-28 18:01:49 +01:00
|
|
|
// If the channel does not exist it will create it.
|
2017-09-21 14:00:14 -05:00
|
|
|
GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// GetGroupChannel gets a group message channel.
|
2018-11-28 18:01:49 +01:00
|
|
|
// If the channel does not exist it will create it.
|
2017-09-21 14:00:14 -05:00
|
|
|
GetGroupChannel(userIds []string) (*model.Channel, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// UpdateChannel updates a channel.
|
|
|
|
|
UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError)
|
|
|
|
|
|
2018-10-15 12:23:46 -04:00
|
|
|
// SearchChannels returns the channels on a team matching the provided search term.
|
2018-10-17 23:43:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-11-20 14:50:34 +01:00
|
|
|
SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError)
|
2018-10-15 12:23:46 -04:00
|
|
|
|
2018-11-30 21:17:17 +05:30
|
|
|
// SearchUsers returns a list of users based on some search criteria.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
SearchUsers(search *model.UserSearch) ([]*model.User, *model.AppError)
|
|
|
|
|
|
2019-02-12 22:41:32 -08:00
|
|
|
// SearchPostsInTeam returns a list of posts in a specific team that match the given params.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
SearchPostsInTeam(teamId string, paramsList []*model.SearchParams) ([]*model.Post, *model.AppError)
|
|
|
|
|
|
2018-04-06 17:08:57 -04:00
|
|
|
// AddChannelMember creates a channel membership for a user.
|
|
|
|
|
AddChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError)
|
|
|
|
|
|
2017-12-05 09:14:03 -05:00
|
|
|
// GetChannelMember gets a channel membership for a user.
|
|
|
|
|
GetChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError)
|
|
|
|
|
|
2018-10-04 01:37:54 +05:30
|
|
|
// GetChannelMembers gets a channel membership for all users.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-04 01:37:54 +05:30
|
|
|
GetChannelMembers(channelId string, page, perPage int) (*model.ChannelMembers, *model.AppError)
|
|
|
|
|
|
2018-10-31 18:59:20 +05:30
|
|
|
// GetChannelMembersByIds gets a channel membership for a particular User
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetChannelMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, *model.AppError)
|
|
|
|
|
|
2019-02-23 11:41:19 -08:00
|
|
|
// GetChannelMembersForUser returns all channel memberships on a team for a user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
GetChannelMembersForUser(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError)
|
|
|
|
|
|
2018-04-06 17:08:57 -04:00
|
|
|
// UpdateChannelMemberRoles updates a user's roles for a channel.
|
|
|
|
|
UpdateChannelMemberRoles(channelId, userId, newRoles string) (*model.ChannelMember, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// UpdateChannelMemberNotifications updates a user's notification properties for a channel.
|
|
|
|
|
UpdateChannelMemberNotifications(channelId, userId string, notifications map[string]string) (*model.ChannelMember, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// DeleteChannelMember deletes a channel membership for a user.
|
|
|
|
|
DeleteChannelMember(channelId, userId string) *model.AppError
|
|
|
|
|
|
2017-08-28 14:19:00 -05:00
|
|
|
// CreatePost creates a post.
|
|
|
|
|
CreatePost(post *model.Post) (*model.Post, *model.AppError)
|
2017-09-21 14:00:14 -05:00
|
|
|
|
2018-08-20 18:22:08 +02:00
|
|
|
// AddReaction add a reaction to a post.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 18:22:08 +02:00
|
|
|
AddReaction(reaction *model.Reaction) (*model.Reaction, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// RemoveReaction remove a reaction from a post.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 18:22:08 +02:00
|
|
|
RemoveReaction(reaction *model.Reaction) *model.AppError
|
|
|
|
|
|
|
|
|
|
// GetReaction get the reactions of a post.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 18:22:08 +02:00
|
|
|
GetReactions(postId string) ([]*model.Reaction, *model.AppError)
|
|
|
|
|
|
2018-07-07 00:32:55 +02:00
|
|
|
// SendEphemeralPost creates an ephemeral post.
|
|
|
|
|
SendEphemeralPost(userId string, post *model.Post) *model.Post
|
|
|
|
|
|
MM-10516: Added support for PostActions in ephemeral posts (#10258)
* Added support for PostActions in ephemeral posts
The general approach is that we take all the metadata that DoPostAction
needs to process client DoPostActionRequests, and store it in a
serialized, encrypted Cookie field, in the PostAction struct.
The client then must send it back, and it is then used to process
PostActions as a fallback top the metadata in the database.
This PR adds a new config setting, `ServiceSettings.ActionCookieSecret`.
In a cluster environment it must be the same for all instances.
- Added type PostActionCookie, and a Cookie string to PostAction.
- Added App.AddActionCookiesToPost.
- Use App.AddActionCookiesToPost in api4.createEphemeralPost,
App.SendEphemeralPost, App.UpdateEphemeralPost.
- Added App.DoPostActionWithCookie to process incoming requests with
cookies. For backward compatibility, it prefers the metadata in the
database; falls back to cookie.
- Added plugin.API.UpdateEphemeralPost and plugin.API.DeleteEphemeralPost.
- Added App.encryptActionCookie/App.decryptActionCookie.
* Style
* Fixed an unfortunate typo, tested with matterpoll
* minor PR feedback
* Fixed uninitialized Context
* Fixed another test failure
* Fixed permission check
* Added api test for DoPostActionWithCookie
* Replaced config.ActionCookieSecret with Server.PostActionCookieSecret
Modeled after AsymetricSigningKey
* style
* Set DeleteAt in DeleteEphemeralPost
* PR feedback
* Removed deadwood comment
* Added EXPERIMENTAL comment to the 2 APIs in question
2019-03-01 10:15:31 -08:00
|
|
|
// UpdateEphemeralPost updates an ephemeral message previously sent to the user.
|
|
|
|
|
// EXPERIMENTAL: This API is experimental and can be changed without advance notice.
|
|
|
|
|
UpdateEphemeralPost(userId string, post *model.Post) *model.Post
|
|
|
|
|
|
|
|
|
|
// DeleteEphemeralPost deletes an ephemeral message previously sent to the user.
|
|
|
|
|
// EXPERIMENTAL: This API is experimental and can be changed without advance notice.
|
|
|
|
|
DeleteEphemeralPost(userId string, post *model.Post)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// DeletePost deletes a post.
|
|
|
|
|
DeletePost(postId string) *model.AppError
|
|
|
|
|
|
2018-10-15 15:19:36 +02:00
|
|
|
// GetPostThread gets a post with all the other posts in the same thread.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-15 15:19:36 +02:00
|
|
|
GetPostThread(postId string) (*model.PostList, *model.AppError)
|
|
|
|
|
|
2017-09-21 14:00:14 -05:00
|
|
|
// GetPost gets a post.
|
|
|
|
|
GetPost(postId string) (*model.Post, *model.AppError)
|
|
|
|
|
|
2018-10-15 16:04:22 +02:00
|
|
|
// GetPostsSince gets posts created after a specified time as Unix time in milliseconds.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-15 16:04:22 +02:00
|
|
|
GetPostsSince(channelId string, time int64) (*model.PostList, *model.AppError)
|
|
|
|
|
|
2018-10-18 18:11:15 +02:00
|
|
|
// GetPostsAfter gets a page of posts that were posted after the post provided.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetPostsAfter(channelId, postId string, page, perPage int) (*model.PostList, *model.AppError)
|
|
|
|
|
|
2018-10-15 19:18:23 +02:00
|
|
|
// GetPostsBefore gets a page of posts that were posted before the post provided.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-15 19:18:23 +02:00
|
|
|
GetPostsBefore(channelId, postId string, page, perPage int) (*model.PostList, *model.AppError)
|
|
|
|
|
|
2018-10-10 18:53:36 +05:30
|
|
|
// GetPostsForChannel gets a list of posts for a channel.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-10 18:53:36 +05:30
|
|
|
GetPostsForChannel(channelId string, page, perPage int) (*model.PostList, *model.AppError)
|
|
|
|
|
|
2019-01-15 14:52:04 +05:30
|
|
|
// GetTeamStats gets a team's statistics
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.8
|
|
|
|
|
GetTeamStats(teamId string) (*model.TeamStats, *model.AppError)
|
|
|
|
|
|
2017-11-27 17:23:35 -05:00
|
|
|
// UpdatePost updates a post.
|
2017-09-21 14:00:14 -05:00
|
|
|
UpdatePost(post *model.Post) (*model.Post, *model.AppError)
|
2017-11-27 17:23:35 -05:00
|
|
|
|
2018-10-17 16:16:15 +02:00
|
|
|
// GetProfileImage gets user's profile image.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-15 16:23:41 +02:00
|
|
|
GetProfileImage(userId string) ([]byte, *model.AppError)
|
|
|
|
|
|
2018-11-15 21:23:03 +01:00
|
|
|
// SetProfileImage sets a user's profile image.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
SetProfileImage(userId string, data []byte) *model.AppError
|
|
|
|
|
|
2018-11-05 19:20:08 +05:30
|
|
|
// GetEmojiList returns a page of custom emoji on the system.
|
|
|
|
|
//
|
|
|
|
|
// The sortBy parameter can be: "name".
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetEmojiList(sortBy string, page, perPage int) ([]*model.Emoji, *model.AppError)
|
|
|
|
|
|
2018-10-15 17:09:30 -04:00
|
|
|
// GetEmojiByName gets an emoji by it's name.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-15 17:09:30 -04:00
|
|
|
GetEmojiByName(name string) (*model.Emoji, *model.AppError)
|
|
|
|
|
|
2018-10-25 13:54:10 +00:00
|
|
|
// GetEmoji returns a custom emoji based on the emojiId string.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetEmoji(emojiId string) (*model.Emoji, *model.AppError)
|
|
|
|
|
|
2018-08-10 11:21:37 -04:00
|
|
|
// CopyFileInfos duplicates the FileInfo objects referenced by the given file ids,
|
|
|
|
|
// recording the given user id as the new creator and returning the new set of file ids.
|
|
|
|
|
//
|
|
|
|
|
// The duplicate FileInfo objects are not initially linked to a post, but may now be passed
|
|
|
|
|
// to CreatePost. Use this API to duplicate a post and its file attachments without
|
|
|
|
|
// actually duplicating the uploaded files.
|
2018-08-02 10:37:31 -04:00
|
|
|
CopyFileInfos(userId string, fileIds []string) ([]string, *model.AppError)
|
|
|
|
|
|
2018-08-20 13:18:25 -03:00
|
|
|
// GetFileInfo gets a File Info for a specific fileId
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 13:18:25 -03:00
|
|
|
GetFileInfo(fileId string) (*model.FileInfo, *model.AppError)
|
|
|
|
|
|
2018-12-13 15:16:42 +05:30
|
|
|
// GetFile gets content of a file by it's ID
|
|
|
|
|
//
|
|
|
|
|
// Minimum Server version: 5.8
|
|
|
|
|
GetFile(fileId string) ([]byte, *model.AppError)
|
|
|
|
|
|
2018-10-17 20:31:51 -04:00
|
|
|
// GetFileLink gets the public link to a file by fileId.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetFileLink(fileId string) (string, *model.AppError)
|
|
|
|
|
|
2018-08-20 13:18:25 -03:00
|
|
|
// ReadFileAtPath reads the file from the backend for a specific path
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 13:18:25 -03:00
|
|
|
ReadFile(path string) ([]byte, *model.AppError)
|
|
|
|
|
|
2018-10-19 04:07:21 +08:00
|
|
|
// GetEmojiImage returns the emoji image.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetEmojiImage(emojiId string) ([]byte, string, *model.AppError)
|
|
|
|
|
|
2018-11-07 21:24:54 +01:00
|
|
|
// UploadFile will upload a file to a channel using a multipart request, to be later attached to a post.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
UploadFile(data []byte, channelId string, filename string) (*model.FileInfo, *model.AppError)
|
|
|
|
|
|
2018-11-19 15:27:17 -05:00
|
|
|
// OpenInteractiveDialog will open an interactive dialog on a user's client that
|
|
|
|
|
// generated the trigger ID. Used with interactive message buttons, menus
|
|
|
|
|
// and slash commands.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
OpenInteractiveDialog(dialog model.OpenDialogRequest) *model.AppError
|
|
|
|
|
|
2018-11-08 19:17:07 +01:00
|
|
|
// Plugin Section
|
|
|
|
|
|
|
|
|
|
// GetPlugins will return a list of plugin manifests for currently active plugins.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetPlugins() ([]*model.Manifest, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// EnablePlugin will enable an plugin installed.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
EnablePlugin(id string) *model.AppError
|
|
|
|
|
|
|
|
|
|
// DisablePlugin will disable an enabled plugin.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
DisablePlugin(id string) *model.AppError
|
|
|
|
|
|
|
|
|
|
// RemovePlugin will disable and delete a plugin.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
RemovePlugin(id string) *model.AppError
|
|
|
|
|
|
|
|
|
|
// GetPluginStatus will return the status of a plugin.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
|
|
|
|
GetPluginStatus(id string) (*model.PluginStatus, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// KV Store Section
|
|
|
|
|
|
2018-07-20 12:03:08 -04:00
|
|
|
// KVSet will store a key-value pair, unique per plugin.
|
2018-06-25 12:33:13 -07:00
|
|
|
KVSet(key string, value []byte) *model.AppError
|
2017-11-27 17:23:35 -05:00
|
|
|
|
2018-10-10 19:55:12 +02:00
|
|
|
// KVSet will store a key-value pair, unique per plugin with an expiry time
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-10 19:55:12 +02:00
|
|
|
KVSetWithExpiry(key string, value []byte, expireInSeconds int64) *model.AppError
|
|
|
|
|
|
2018-07-20 12:03:08 -04:00
|
|
|
// KVGet will retrieve a value based on the key. Returns nil for non-existent keys.
|
2018-06-25 12:33:13 -07:00
|
|
|
KVGet(key string) ([]byte, *model.AppError)
|
2017-11-27 17:23:35 -05:00
|
|
|
|
2018-07-20 12:03:08 -04:00
|
|
|
// KVDelete will remove a key-value pair. Returns nil for non-existent keys.
|
2018-06-25 12:33:13 -07:00
|
|
|
KVDelete(key string) *model.AppError
|
2018-06-27 08:46:38 -04:00
|
|
|
|
2018-10-10 19:55:12 +02:00
|
|
|
// KVDeleteAll will remove all key-value pairs for a plugin.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-10 19:55:12 +02:00
|
|
|
KVDeleteAll() *model.AppError
|
|
|
|
|
|
2018-10-03 13:04:37 -07:00
|
|
|
// KVList will list all keys for a plugin.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.6
|
2018-10-03 13:04:37 -07:00
|
|
|
KVList(page, perPage int) ([]string, *model.AppError)
|
|
|
|
|
|
2018-06-27 08:46:38 -04:00
|
|
|
// PublishWebSocketEvent sends an event to WebSocket connections.
|
2019-01-10 03:29:26 +09:00
|
|
|
// event is the type and will be prepended with "custom_<pluginid>_".
|
|
|
|
|
// payload is the data sent with the event. Interface values must be primitive Go types or mattermost-server/model types.
|
|
|
|
|
// broadcast determines to which users to send the event.
|
2018-06-27 08:46:38 -04:00
|
|
|
PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
|
2018-07-03 09:58:28 -07:00
|
|
|
|
2018-08-20 18:22:08 +02:00
|
|
|
// HasPermissionTo check if the user has the permission at system scope.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 18:22:08 +02:00
|
|
|
HasPermissionTo(userId string, permission *model.Permission) bool
|
|
|
|
|
|
|
|
|
|
// HasPermissionToTeam check if the user has the permission at team scope.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 18:22:08 +02:00
|
|
|
HasPermissionToTeam(userId, teamId string, permission *model.Permission) bool
|
|
|
|
|
|
|
|
|
|
// HasPermissionToChannel check if the user has the permission at channel scope.
|
2018-10-17 16:16:15 +02:00
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.3
|
2018-08-20 18:22:08 +02:00
|
|
|
HasPermissionToChannel(userId, channelId string, permission *model.Permission) bool
|
|
|
|
|
|
2018-07-03 09:58:28 -07:00
|
|
|
// LogDebug writes a log message to the Mattermost server log file.
|
|
|
|
|
// Appropriate context such as the plugin name will already be added as fields so plugins
|
|
|
|
|
// do not need to add that info.
|
|
|
|
|
// keyValuePairs should be primitive go types or other values that can be encoded by encoding/gob
|
|
|
|
|
LogDebug(msg string, keyValuePairs ...interface{})
|
|
|
|
|
|
|
|
|
|
// LogInfo writes a log message to the Mattermost server log file.
|
|
|
|
|
// Appropriate context such as the plugin name will already be added as fields so plugins
|
|
|
|
|
// do not need to add that info.
|
|
|
|
|
// keyValuePairs should be primitive go types or other values that can be encoded by encoding/gob
|
|
|
|
|
LogInfo(msg string, keyValuePairs ...interface{})
|
|
|
|
|
|
|
|
|
|
// LogError writes a log message to the Mattermost server log file.
|
|
|
|
|
// Appropriate context such as the plugin name will already be added as fields so plugins
|
|
|
|
|
// do not need to add that info.
|
|
|
|
|
// keyValuePairs should be primitive go types or other values that can be encoded by encoding/gob
|
|
|
|
|
LogError(msg string, keyValuePairs ...interface{})
|
|
|
|
|
|
|
|
|
|
// LogWarn writes a log message to the Mattermost server log file.
|
|
|
|
|
// Appropriate context such as the plugin name will already be added as fields so plugins
|
|
|
|
|
// do not need to add that info.
|
|
|
|
|
// keyValuePairs should be primitive go types or other values that can be encoded by encoding/gob
|
|
|
|
|
LogWarn(msg string, keyValuePairs ...interface{})
|
2019-01-10 10:06:14 +01:00
|
|
|
|
|
|
|
|
// SendMail sends an email to a specific address
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.7
|
|
|
|
|
SendMail(to, subject, htmlBody string) *model.AppError
|
MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)
* bots model, store and api
Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119
* uncomment tests incorrectly commented, and fix merge issues
* add etags support
* add missing licenses
* remove unused sqlbuilder.go (for now...)
* rejig permissions
* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS
* conform to general rest api pattern
* eliminate redundant http.StatusOK
* Update api4/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* s/model.UserFromBotModel/model.UserFromBot/g
* Update model/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* Update model/client4.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* move sessionHasPermissionToManageBot to app/authorization.go
* use api.ApiSessionRequired for createBot
* introduce BOT_DESCRIPTION_MAX_RUNES constant
* MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings
* Add additional config settings to tests
* upgrade db to 5.7 (#10019)
* MM-13526 Add validation when setting a user's Locale field (#10022)
* Fix typos (#10024)
* Fixing first user being created with system admin privilages without being explicity specified. (#10014)
* Revert "Support for Embeded chat (#9129)" (#10017)
This reverts commit 3fcecd521a5c6ccfdb52fb4c3fb1f8c6ea528a4e.
* s/DisableBot/UpdateBotActive
* add permissions on upgrade
* Update NOTICE.txt (#10054)
- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates
* avoid leaking bot knowledge without permission
* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts
* 6798 added the permsission check before getting the reactions
* GH-6798 added a new app function for the new endpoint
* 6798 added a store method to get reactions for multiple posts
* 6798 connected the app function with the new store function
* 6798 fixed the review comments
* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)
Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023
* Trigger Login Hooks with OAuth (#10061)
* make BotStore.GetAll deterministic even on duplicate CreateAt
* fix spurious TestMuteCommandSpecificChannel test failure
See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw
* fix race in TestExportUserChannels
* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway
* MM-13117: bot tokens (#10111)
* eliminate redundant Client/AdminClient declarations
* harden TestUpdateChannelScheme to API failures
* eliminate unnecessary config restoration
* minor cleanup
* make TestGenerateMfaSecret config dependency explicit
* TestCreateUserAccessToken for bots
* TestGetUserAccessToken* for bots
* leverage SessionHasPermissionToUserOrBot for user token APIs
* Test(Revoke|Disable|Enable)UserAccessToken
* make EnableUserAccessTokens explicit, so as to not rely on local config.json
* uncomment TestResetPassword, but still skip
* mark assert(Invalid)Token as helper
* fix whitespace issues
* fix mangled comments
* MM-13116: bot plugin api (#10113)
* MM-13117: expose bot API to plugins
This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.
* gofmt issues
* expunge use of BotList in plugin/client API
* introduce model.BotGetOptions
* use botUserId term for clarity
* MM-13129 Adding functionality to deal with orphaned bots (#10238)
* Add way to list orphaned bots.
* Add /assign route to modify ownership of bot accounts.
* Apply suggestions from code review
Co-Authored-By: crspeller <crspeller@gmail.com>
* MM-13120: add IsBot field to returned user objects (#10103)
* MM-13104: forbid bot login (#10251)
* MM-13104: disallow bot login
* fix shadowing
* MM-13136 Disable user bots when user is disabled. (#10293)
* Disable user bots when user is disabled.
* Grammer.
Co-Authored-By: crspeller <crspeller@gmail.com>
* Fixing bot branch for test changes.
* Don't use external dependancies in bot plugin tests.
* Rename bot CreatorId to OwnerId
* Adding ability to re-enable bots
* Fixing IsBot to not attempt to be saved to DB.
* Adding diagnostics and licencing counting for bot accounts.
* Modifying gorp to allow reading of '-' fields.
* Removing unnessisary nil values from UserCountOptions.
* Changing comment to GoDoc format
* Improving user count SQL
* Some improvments from feedback.
* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
|
|
|
|
|
|
|
|
// CreateBot creates the given bot and corresponding user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
CreateBot(bot *model.Bot) (*model.Bot, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// PatchBot applies the given patch to the bot and corresponding user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// GetBot returns the given bot.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// GetBots returns the requested page of bots.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
GetBots(options *model.BotGetOptions) ([]*model.Bot, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// UpdateBotActive marks a bot as active or inactive, along with its corresponding user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
UpdateBotActive(botUserId string, active bool) (*model.Bot, *model.AppError)
|
|
|
|
|
|
|
|
|
|
// PermanentDeleteBot permanently deletes a bot and its corresponding user.
|
|
|
|
|
//
|
|
|
|
|
// Minimum server version: 5.10
|
|
|
|
|
PermanentDeleteBot(botUserId string) *model.AppError
|
2018-06-25 12:33:13 -07:00
|
|
|
}
|
|
|
|
|
|
2018-07-13 10:29:50 -04:00
|
|
|
var handshake = plugin.HandshakeConfig{
|
2018-06-25 12:33:13 -07:00
|
|
|
ProtocolVersion: 1,
|
|
|
|
|
MagicCookieKey: "MATTERMOST_PLUGIN",
|
|
|
|
|
MagicCookieValue: "Securely message teams, anywhere.",
|
2017-08-16 17:23:38 -05:00
|
|
|
}
|