diff options
author | Duco van Amstel <helcaraxan@gmail.com> | 2018-11-18 17:55:05 +0000 |
---|---|---|
committer | Wim <wim@42.be> | 2018-11-25 21:21:04 +0100 |
commit | 09875fe1603307080f3a4172985c5dca3bd9912d (patch) | |
tree | a23220772f6f6597d509ca71b2df3480a77b8076 /vendor/github.com/mattermost/mattermost-server/model/push_response.go | |
parent | f716b8fc0ff90f47b61e218ef34019b38bd70e0d (diff) | |
download | matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.gz matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.bz2 matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.zip |
Update direct dependencies where possible
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/model/push_response.go')
-rw-r--r-- | vendor/github.com/mattermost/mattermost-server/model/push_response.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/model/push_response.go b/vendor/github.com/mattermost/mattermost-server/model/push_response.go new file mode 100644 index 00000000..1434a2b1 --- /dev/null +++ b/vendor/github.com/mattermost/mattermost-server/model/push_response.go @@ -0,0 +1,54 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" +) + +const ( + PUSH_STATUS = "status" + PUSH_STATUS_OK = "OK" + PUSH_STATUS_FAIL = "FAIL" + PUSH_STATUS_REMOVE = "REMOVE" + PUSH_STATUS_ERROR_MSG = "error" +) + +type PushResponse map[string]string + +func NewOkPushResponse() PushResponse { + m := make(map[string]string) + m[PUSH_STATUS] = PUSH_STATUS_OK + return m +} + +func NewRemovePushResponse() PushResponse { + m := make(map[string]string) + m[PUSH_STATUS] = PUSH_STATUS_REMOVE + return m +} + +func NewErrorPushResponse(message string) PushResponse { + m := make(map[string]string) + m[PUSH_STATUS] = PUSH_STATUS_FAIL + m[PUSH_STATUS_ERROR_MSG] = message + return m +} + +func (me *PushResponse) ToJson() string { + b, _ := json.Marshal(me) + return string(b) +} + +func PushResponseFromJson(data io.Reader) PushResponse { + decoder := json.NewDecoder(data) + + var objmap PushResponse + if err := decoder.Decode(&objmap); err != nil { + return make(map[string]string) + } else { + return objmap + } +} |