summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/command_response.go2
-rw-r--r--model/outgoing_webhook.go28
-rw-r--r--model/outgoing_webhook_test.go13
3 files changed, 43 insertions, 0 deletions
diff --git a/model/command_response.go b/model/command_response.go
index d17bd00e3..f5c628b71 100644
--- a/model/command_response.go
+++ b/model/command_response.go
@@ -20,6 +20,8 @@ type CommandResponse struct {
Text string `json:"text"`
Username string `json:"username"`
IconURL string `json:"icon_url"`
+ Type string `json:"type"`
+ Props StringInterface `json:"props"`
GotoLocation string `json:"goto_location"`
Attachments []*SlackAttachment `json:"attachments"`
}
diff --git a/model/outgoing_webhook.go b/model/outgoing_webhook.go
index 59408c24e..14c6f2269 100644
--- a/model/outgoing_webhook.go
+++ b/model/outgoing_webhook.go
@@ -45,6 +45,14 @@ type OutgoingWebhookPayload struct {
FileIds string `json:"file_ids"`
}
+type OutgoingWebhookResponse struct {
+ Text *string `json:"text"`
+ Username string `json:"username"`
+ IconURL string `json:"icon_url"`
+ Props StringInterface `json:"props"`
+ Type string `json:"type"`
+}
+
func (o *OutgoingWebhookPayload) ToJSON() string {
b, err := json.Marshal(o)
if err != nil {
@@ -112,6 +120,26 @@ func OutgoingWebhookListFromJson(data io.Reader) []*OutgoingWebhook {
}
}
+func (o *OutgoingWebhookResponse) ToJson() string {
+ b, err := json.Marshal(o)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func OutgoingWebhookResponseFromJson(data io.Reader) *OutgoingWebhookResponse {
+ decoder := json.NewDecoder(data)
+ var o OutgoingWebhookResponse
+ err := decoder.Decode(&o)
+ if err == nil {
+ return &o
+ } else {
+ return nil
+ }
+}
+
func (o *OutgoingWebhook) IsValid() *AppError {
if len(o.Id) != 26 {
diff --git a/model/outgoing_webhook_test.go b/model/outgoing_webhook_test.go
index 431b1f6c1..2412271b5 100644
--- a/model/outgoing_webhook_test.go
+++ b/model/outgoing_webhook_test.go
@@ -176,3 +176,16 @@ func TestOutgoingWebhookTriggerWordStartsWith(t *testing.T) {
t.Fatal("Should return false")
}
}
+
+func TestOutgoingWebhookResponseJson(t *testing.T) {
+ o := OutgoingWebhookResponse{}
+ o.Text = new(string)
+ *o.Text = "some text"
+
+ json := o.ToJson()
+ ro := OutgoingWebhookResponseFromJson(strings.NewReader(json))
+
+ if *o.Text != *ro.Text {
+ t.Fatal("Text does not match")
+ }
+}