diff options
author | Jesse Hallam <jesse.hallam@gmail.com> | 2018-01-03 10:35:36 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-01-03 10:35:36 -0500 |
commit | e5dad3cf681fb038ce5dd3dcf7b5468d59b8ea8e (patch) | |
tree | d3040d03a076b5e3b0d991bcb5d4d703f9a45c07 /model | |
parent | 15cc4497588537f3f9b81d6f97228fae946fa008 (diff) | |
download | chat-e5dad3cf681fb038ce5dd3dcf7b5468d59b8ea8e.tar.gz chat-e5dad3cf681fb038ce5dd3dcf7b5468d59b8ea8e.tar.bz2 chat-e5dad3cf681fb038ce5dd3dcf7b5468d59b8ea8e.zip |
[PLT-8173] Strip the post_ prefix on incoming webhook overrides. (#8019)
Diffstat (limited to 'model')
-rw-r--r-- | model/incoming_webhook.go | 28 | ||||
-rw-r--r-- | model/incoming_webhook_test.go | 8 |
2 files changed, 18 insertions, 18 deletions
diff --git a/model/incoming_webhook.go b/model/incoming_webhook.go index 2eb007340..3e0488d2b 100644 --- a/model/incoming_webhook.go +++ b/model/incoming_webhook.go @@ -16,17 +16,17 @@ const ( ) type IncomingWebhook struct { - Id string `json:"id"` - CreateAt int64 `json:"create_at"` - UpdateAt int64 `json:"update_at"` - DeleteAt int64 `json:"delete_at"` - UserId string `json:"user_id"` - ChannelId string `json:"channel_id"` - TeamId string `json:"team_id"` - DisplayName string `json:"display_name"` - Description string `json:"description"` - PostUsername string `json:"post_username"` - PostIconURL string `json:"post_icon_url"` + Id string `json:"id"` + CreateAt int64 `json:"create_at"` + UpdateAt int64 `json:"update_at"` + DeleteAt int64 `json:"delete_at"` + UserId string `json:"user_id"` + ChannelId string `json:"channel_id"` + 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 { @@ -114,12 +114,12 @@ func (o *IncomingWebhook) IsValid() *AppError { return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.description.app_error", nil, "", http.StatusBadRequest) } - if len(o.PostUsername) > 64 { + if len(o.Username) > 64 { return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.username.app_error", nil, "", http.StatusBadRequest) } - if len(o.PostIconURL) > 1024 { - return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.post_icon_url.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 diff --git a/model/incoming_webhook_test.go b/model/incoming_webhook_test.go index 13b416eb0..5498a6a0c 100644 --- a/model/incoming_webhook_test.go +++ b/model/incoming_webhook_test.go @@ -90,22 +90,22 @@ func TestIncomingWebhookIsValid(t *testing.T) { t.Fatal(err) } - o.PostUsername = strings.Repeat("1", 65) + o.Username = strings.Repeat("1", 65) if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } - o.PostUsername = strings.Repeat("1", 64) + o.Username = strings.Repeat("1", 64) if err := o.IsValid(); err != nil { t.Fatal(err) } - o.PostIconURL = strings.Repeat("1", 1025) + o.IconURL = strings.Repeat("1", 1025) if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } - o.PostIconURL = strings.Repeat("1", 1024) + o.IconURL = strings.Repeat("1", 1024) if err := o.IsValid(); err != nil { t.Fatal(err) } |