From cea1796f0698956e4fab57a0015b292854bbbcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Mon, 20 Aug 2018 18:22:08 +0200 Subject: Adding Permissions check and reactions function to plugins API (#9273) * Adding reactions functions * Adding permissions checking in the plugins api --- plugin/api.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'plugin/api.go') diff --git a/plugin/api.go b/plugin/api.go index 256ac9f81..370c28268 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -143,6 +143,15 @@ type API interface { // CreatePost creates a post. CreatePost(post *model.Post) (*model.Post, *model.AppError) + // AddReaction add a reaction to a post. + AddReaction(reaction *model.Reaction) (*model.Reaction, *model.AppError) + + // RemoveReaction remove a reaction from a post. + RemoveReaction(reaction *model.Reaction) *model.AppError + + // GetReaction get the reactions of a post. + GetReactions(postId string) ([]*model.Reaction, *model.AppError) + // SendEphemeralPost creates an ephemeral post. SendEphemeralPost(userId string, post *model.Post) *model.Post @@ -184,6 +193,15 @@ type API interface { // broadcast determines to which users to send the event PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) + // HasPermissionTo check if the user has the permission at system scope. + HasPermissionTo(userId string, permission *model.Permission) bool + + // HasPermissionToTeam check if the user has the permission at team scope. + HasPermissionToTeam(userId, teamId string, permission *model.Permission) bool + + // HasPermissionToChannel check if the user has the permission at channel scope. + HasPermissionToChannel(userId, channelId string, permission *model.Permission) bool + // 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. -- cgit v1.2.3-1-g7c22