diff options
Diffstat (limited to 'model/outgoing_webhook.go')
-rw-r--r-- | model/outgoing_webhook.go | 28 |
1 files changed, 28 insertions, 0 deletions
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 { |