diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-10-25 08:17:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-25 08:17:17 -0400 |
commit | 16b845c0d77535ea306339f7a8bd22fc72f8a3c5 (patch) | |
tree | e768b8d1ca5cc3f2e55207ea73c5954b37f708ed /model/client4.go | |
parent | 9c0575ce6ef662c18ad7eb91bf6084c6fac1b7ae (diff) | |
download | chat-16b845c0d77535ea306339f7a8bd22fc72f8a3c5.tar.gz chat-16b845c0d77535ea306339f7a8bd22fc72f8a3c5.tar.bz2 chat-16b845c0d77535ea306339f7a8bd22fc72f8a3c5.zip |
Differentiate between installed and activated states for plugins (#7706)
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/model/client4.go b/model/client4.go index dc5a25bec..1c20954d8 100644 --- a/model/client4.go +++ b/model/client4.go @@ -3150,12 +3150,12 @@ func (c *Client4) UploadPlugin(file io.Reader) (*Manifest, *Response) { // GetPlugins will return a list of plugin manifests for currently active plugins. // WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE. -func (c *Client4) GetPlugins() ([]*Manifest, *Response) { +func (c *Client4) GetPlugins() (*PluginsResponse, *Response) { if r, err := c.DoApiGet(c.GetPluginsRoute(), ""); err != nil { return nil, BuildErrorResponse(r, err) } else { defer closeBody(r) - return ManifestListFromJson(r.Body), BuildResponse(r) + return PluginsResponseFromJson(r.Body), BuildResponse(r) } } @@ -3180,3 +3180,25 @@ func (c *Client4) GetWebappPlugins() ([]*Manifest, *Response) { return ManifestListFromJson(r.Body), BuildResponse(r) } } + +// ActivatePlugin will activate an plugin installed. +// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE. +func (c *Client4) ActivatePlugin(id string) (bool, *Response) { + if r, err := c.DoApiPost(c.GetPluginRoute(id)+"/activate", ""); err != nil { + return false, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} + +// DeactivatePlugin will deactivate an active plugin. +// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE. +func (c *Client4) DeactivatePlugin(id string) (bool, *Response) { + if r, err := c.DoApiPost(c.GetPluginRoute(id)+"/deactivate", ""); err != nil { + return false, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} |