diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-09-15 08:51:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-15 08:51:46 -0400 |
commit | 2628022275ef64fde95545abe4634b4bd7177844 (patch) | |
tree | 25d451b81d720f44aa09b20389be7fbb75b7864e /api4/plugin.go | |
parent | 2a6cd44f23e1b3207debaa73801f0c63a2c81126 (diff) | |
download | chat-2628022275ef64fde95545abe4634b4bd7177844.tar.gz chat-2628022275ef64fde95545abe4634b4bd7177844.tar.bz2 chat-2628022275ef64fde95545abe4634b4bd7177844.zip |
PLT-7622 Improvements to server handling of webapp plugins (#7445)
* Improvements to server handling of webapp plugins
* Fix newline
* Update manifest function names
Diffstat (limited to 'api4/plugin.go')
-rw-r--r-- | api4/plugin.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/api4/plugin.go b/api4/plugin.go index 5b030e71d..ac1620335 100644 --- a/api4/plugin.go +++ b/api4/plugin.go @@ -25,6 +25,8 @@ func InitPlugin() { BaseRoutes.Plugins.Handle("", ApiSessionRequired(getPlugins)).Methods("GET") BaseRoutes.Plugin.Handle("", ApiSessionRequired(removePlugin)).Methods("DELETE") + BaseRoutes.Plugins.Handle("/webapp", ApiHandler(getWebappPlugins)).Methods("GET") + } func uploadPlugin(c *Context, w http.ResponseWriter, r *http.Request) { @@ -118,3 +120,25 @@ func removePlugin(c *Context, w http.ResponseWriter, r *http.Request) { ReturnStatusOK(w) } + +func getWebappPlugins(c *Context, w http.ResponseWriter, r *http.Request) { + if !*utils.Cfg.PluginSettings.Enable { + c.Err = model.NewAppError("getWebappPlugins", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented) + return + } + + manifests, err := c.App.GetActivePluginManifests() + if err != nil { + c.Err = err + return + } + + clientManifests := []*model.Manifest{} + for _, m := range manifests { + if m.HasClient() { + clientManifests = append(clientManifests, m.ClientManifest()) + } + } + + w.Write([]byte(model.ManifestListToJson(clientManifests))) +} |