From 2628022275ef64fde95545abe4634b4bd7177844 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 15 Sep 2017 08:51:46 -0400 Subject: PLT-7622 Improvements to server handling of webapp plugins (#7445) * Improvements to server handling of webapp plugins * Fix newline * Update manifest function names --- api4/plugin.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'api4/plugin.go') 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))) +} -- cgit v1.2.3-1-g7c22