summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorMartin Kraft <martinkraft@gmail.com>2018-05-24 08:40:52 -0400
committerMartin Kraft <martinkraft@gmail.com>2018-05-24 08:40:52 -0400
commit69304fb54da5300941a49364e4344c2c65e654d6 (patch)
treede20c2e8a479ae3d13bcd21abc3dff067afa602e /api4
parente46b94fa66c029b9a493fdc6ff7bcb98e9651568 (diff)
parent47f3c064db885c2cb2e75c195ea24e2ef687891d (diff)
downloadchat-69304fb54da5300941a49364e4344c2c65e654d6.tar.gz
chat-69304fb54da5300941a49364e4344c2c65e654d6.tar.bz2
chat-69304fb54da5300941a49364e4344c2c65e654d6.zip
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'api4')
-rw-r--r--api4/plugin.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/api4/plugin.go b/api4/plugin.go
index 37fbf12cd..ab026ab5f 100644
--- a/api4/plugin.go
+++ b/api4/plugin.go
@@ -23,6 +23,7 @@ func (api *API) InitPlugin() {
api.BaseRoutes.Plugins.Handle("", api.ApiSessionRequired(getPlugins)).Methods("GET")
api.BaseRoutes.Plugin.Handle("", api.ApiSessionRequired(removePlugin)).Methods("DELETE")
+ api.BaseRoutes.Plugins.Handle("/statuses", api.ApiSessionRequired(getPluginStatuses)).Methods("GET")
api.BaseRoutes.Plugin.Handle("/activate", api.ApiSessionRequired(activatePlugin)).Methods("POST")
api.BaseRoutes.Plugin.Handle("/deactivate", api.ApiSessionRequired(deactivatePlugin)).Methods("POST")
@@ -97,6 +98,26 @@ func getPlugins(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(response.ToJson()))
}
+func getPluginStatuses(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !*c.App.Config().PluginSettings.Enable {
+ c.Err = model.NewAppError("getPluginStatuses", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
+ return
+ }
+
+ if !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
+ return
+ }
+
+ response, err := c.App.GetClusterPluginStatuses()
+ if err != nil {
+ c.Err = err
+ return
+ }
+
+ w.Write([]byte(response.ToJson()))
+}
+
func removePlugin(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequirePluginId()
if c.Err != nil {
@@ -104,7 +125,7 @@ func removePlugin(c *Context, w http.ResponseWriter, r *http.Request) {
}
if !*c.App.Config().PluginSettings.Enable {
- c.Err = model.NewAppError("getPlugins", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
+ c.Err = model.NewAppError("removePlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
return
}