diff options
author | =Corey Hulen <corey@hulen.com> | 2016-01-08 12:41:26 -0600 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-01-08 12:41:26 -0600 |
commit | 3fba8e42b140c1189bf3c06882cce5e2231e63da (patch) | |
tree | 7a0721cecf6624fc9c1fd71449628472b941ddeb /model/command_response.go | |
parent | 001a4448ca5fb0018eeb442915b473b121c04bf3 (diff) | |
download | chat-3fba8e42b140c1189bf3c06882cce5e2231e63da.tar.gz chat-3fba8e42b140c1189bf3c06882cce5e2231e63da.tar.bz2 chat-3fba8e42b140c1189bf3c06882cce5e2231e63da.zip |
partial fix for UI
Diffstat (limited to 'model/command_response.go')
-rw-r--r-- | model/command_response.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/model/command_response.go b/model/command_response.go new file mode 100644 index 000000000..001384864 --- /dev/null +++ b/model/command_response.go @@ -0,0 +1,40 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" +) + +const ( + COMMAND_RESPONSE_TYPE_IN_CHANNEL = "in_channel" + COMMAND_RESPONSE_TYPE_EPHEMERAL = "ephemeral" +) + +type CommandResponse struct { + ResponseType string `json:"response_type"` + Text string `json:"text"` + Attachments interface{} `json:"attachments"` +} + +func (o *CommandResponse) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func CommandResponseFromJson(data io.Reader) *CommandResponse { + decoder := json.NewDecoder(data) + var o CommandResponse + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} |