summaryrefslogtreecommitdiffstats
path: root/model/plugins_response.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-10-25 08:17:17 -0400
committerGitHub <noreply@github.com>2017-10-25 08:17:17 -0400
commit16b845c0d77535ea306339f7a8bd22fc72f8a3c5 (patch)
treee768b8d1ca5cc3f2e55207ea73c5954b37f708ed /model/plugins_response.go
parent9c0575ce6ef662c18ad7eb91bf6084c6fac1b7ae (diff)
downloadchat-16b845c0d77535ea306339f7a8bd22fc72f8a3c5.tar.gz
chat-16b845c0d77535ea306339f7a8bd22fc72f8a3c5.tar.bz2
chat-16b845c0d77535ea306339f7a8bd22fc72f8a3c5.zip
Differentiate between installed and activated states for plugins (#7706)
Diffstat (limited to 'model/plugins_response.go')
-rw-r--r--model/plugins_response.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/model/plugins_response.go b/model/plugins_response.go
new file mode 100644
index 000000000..d726e491e
--- /dev/null
+++ b/model/plugins_response.go
@@ -0,0 +1,31 @@
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type PluginsResponse struct {
+ Active []*Manifest `json:"active"`
+ Inactive []*Manifest `json:"inactive"`
+}
+
+func (m *PluginsResponse) ToJson() string {
+ b, err := json.Marshal(m)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func PluginsResponseFromJson(data io.Reader) *PluginsResponse {
+ decoder := json.NewDecoder(data)
+ var m PluginsResponse
+ err := decoder.Decode(&m)
+ if err == nil {
+ return &m
+ } else {
+ return nil
+ }
+}