diff options
Diffstat (limited to 'model/incoming_webhook.go')
-rw-r--r-- | model/incoming_webhook.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/model/incoming_webhook.go b/model/incoming_webhook.go index 9b9969b96..be1984244 100644 --- a/model/incoming_webhook.go +++ b/model/incoming_webhook.go @@ -23,6 +23,13 @@ type IncomingWebhook struct { TeamId string `json:"team_id"` } +type IncomingWebhookRequest struct { + Text string `json:"text"` + Username string `json:"username"` + IconURL string `json:"icon_url"` + ChannelName string `json:"channel"` +} + func (o *IncomingWebhook) ToJson() string { b, err := json.Marshal(o) if err != nil { @@ -104,3 +111,14 @@ func (o *IncomingWebhook) PreSave() { func (o *IncomingWebhook) PreUpdate() { o.UpdateAt = GetMillis() } + +func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest { + decoder := json.NewDecoder(data) + var o IncomingWebhookRequest + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} |