diff options
author | Wim <wim@42.be> | 2018-02-09 00:11:04 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-09 00:11:04 +0100 |
commit | 5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811 (patch) | |
tree | 09bcb3f02f968867c2ca84db1f28594dd0afb967 /vendor/github.com/mattermost/platform/model/incoming_webhook.go | |
parent | 1d33e60e36fa7b0e361990ac347ee8d620d67dcc (diff) | |
download | matterbridge-msglm-5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811.tar.gz matterbridge-msglm-5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811.tar.bz2 matterbridge-msglm-5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811.zip |
Update vendor (github.com/mattermost)
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/incoming_webhook.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/incoming_webhook.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/vendor/github.com/mattermost/platform/model/incoming_webhook.go b/vendor/github.com/mattermost/platform/model/incoming_webhook.go index ce755f88..3e0488d2 100644 --- a/vendor/github.com/mattermost/platform/model/incoming_webhook.go +++ b/vendor/github.com/mattermost/platform/model/incoming_webhook.go @@ -25,6 +25,8 @@ type IncomingWebhook struct { TeamId string `json:"team_id"` DisplayName string `json:"display_name"` Description string `json:"description"` + Username string `json:"username"` + IconURL string `json:"icon_url"` } type IncomingWebhookRequest struct { @@ -112,6 +114,14 @@ func (o *IncomingWebhook) IsValid() *AppError { return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.description.app_error", nil, "", http.StatusBadRequest) } + if len(o.Username) > 64 { + return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.username.app_error", nil, "", http.StatusBadRequest) + } + + if len(o.IconURL) > 1024 { + return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.icon_url.app_error", nil, "", http.StatusBadRequest) + } + return nil } @@ -193,7 +203,7 @@ func decodeIncomingWebhookRequest(by []byte) (*IncomingWebhookRequest, error) { } } -func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest { +func IncomingWebhookRequestFromJson(data io.Reader) (*IncomingWebhookRequest, *AppError) { buf := new(bytes.Buffer) buf.ReadFrom(data) by := buf.Bytes() @@ -204,12 +214,11 @@ func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest { if err != nil { o, err = decodeIncomingWebhookRequest(escapeControlCharsFromPayload(by)) if err != nil { - return nil + return nil, NewAppError("IncomingWebhookRequestFromJson", "Unable to parse incoming data", nil, err.Error(), http.StatusBadRequest) } } - o.Text = ExpandAnnouncement(o.Text) - o.Attachments = ProcessSlackAttachments(o.Attachments) + o.Attachments = StringifySlackFieldValue(o.Attachments) - return o + return o, nil } |