summaryrefslogtreecommitdiffstats
path: root/plugin/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/api.go')
-rw-r--r--plugin/api.go81
1 files changed, 73 insertions, 8 deletions
diff --git a/plugin/api.go b/plugin/api.go
index d62c2f069..2b15a3d09 100644
--- a/plugin/api.go
+++ b/plugin/api.go
@@ -4,6 +4,7 @@
package plugin
import (
+ "github.com/hashicorp/go-plugin"
"github.com/mattermost/mattermost-server/model"
)
@@ -23,6 +24,12 @@ type API interface {
// UnregisterCommand unregisters a command previously registered via RegisterCommand.
UnregisterCommand(teamId, trigger string) error
+ // GetConfig fetches the currently persisted config
+ GetConfig() *model.Config
+
+ // SaveConfig sets the given config and persists the changes
+ SaveConfig(config *model.Config) *model.AppError
+
// CreateUser creates a user.
CreateUser(user *model.User) (*model.User, *model.AppError)
@@ -47,6 +54,9 @@ type API interface {
// DeleteTeam deletes a team.
DeleteTeam(teamId string) *model.AppError
+ // GetTeam gets all teams.
+ GetTeams() ([]*model.Team, *model.AppError)
+
// GetTeam gets a team.
GetTeam(teamId string) (*model.Team, *model.AppError)
@@ -56,12 +66,33 @@ type API interface {
// UpdateTeam updates a team.
UpdateTeam(team *model.Team) (*model.Team, *model.AppError)
+ // 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.
+ GetTeamMembers(teamId string, offset, limit int) ([]*model.TeamMember, *model.AppError)
+
+ // GetTeamMember returns a specific membership.
+ GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
+
+ // UpdateTeamMemberRoles updates the role for a team membership.
+ UpdateTeamMemberRoles(teamId, userId, newRoles string) (*model.TeamMember, *model.AppError)
+
// CreateChannel creates a channel.
CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError)
// DeleteChannel deletes a channel.
DeleteChannel(channelId string) *model.AppError
+ // GetChannels gets a list of all channels.
+ GetPublicChannelsForTeam(teamId string, offset, limit int) (*model.ChannelList, *model.AppError)
+
// GetChannel gets a channel.
GetChannel(channelId string) (*model.Channel, *model.AppError)
@@ -95,6 +126,9 @@ type API interface {
// CreatePost creates a post.
CreatePost(post *model.Post) (*model.Post, *model.AppError)
+ // SendEphemeralPost creates an ephemeral post.
+ SendEphemeralPost(userId string, post *model.Post) *model.Post
+
// DeletePost deletes a post.
DeletePost(postId string) *model.AppError
@@ -104,17 +138,48 @@ type API interface {
// UpdatePost updates a post.
UpdatePost(post *model.Post) (*model.Post, *model.AppError)
- // KeyValueStore returns an object for accessing the persistent key value storage.
- KeyValueStore() KeyValueStore
-}
-
-type KeyValueStore interface {
// Set will store a key-value pair, unique per plugin.
- Set(key string, value []byte) *model.AppError
+ KVSet(key string, value []byte) *model.AppError
// Get will retrieve a value based on the key. Returns nil for non-existent keys.
- Get(key string) ([]byte, *model.AppError)
+ KVGet(key string) ([]byte, *model.AppError)
// Delete will remove a key-value pair. Returns nil for non-existent keys.
- Delete(key string) *model.AppError
+ KVDelete(key string) *model.AppError
+
+ // PublishWebSocketEvent sends an event to WebSocket connections.
+ // 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
+ PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
+
+ // 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{})
+}
+
+var Handshake = plugin.HandshakeConfig{
+ ProtocolVersion: 1,
+ MagicCookieKey: "MATTERMOST_PLUGIN",
+ MagicCookieValue: "Securely message teams, anywhere.",
}