Commit 50af3a19 authored by n1aba's avatar n1aba Committed by Carlos Tadeu Panato Junior

MM-11703: Update incoming and outgoing webhook description to 500 characters (#9265)

* MM-11703: Update incoming and outgoing webhook description to 500 characters

* MM-11703: Add upgrade code

* MM-11703: Remove MAX_DESCRIPTION_LENGTH constants

* MM-11703: GOFMT

* MM-11703: Move upgrade code to version 5.3

* MM-11703: Comment back upgrade to 5.3.0

* MM-11703: Add API errors back

* MM-11703: Copy-Paste
parent 30fa6eca
......@@ -93,7 +93,7 @@ func (o *IncomingWebhook) IsValid() *AppError {
return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.display_name.app_error", nil, "", http.StatusBadRequest)
}
if len(o.Description) > 128 {
if len(o.Description) > 500 {
return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.description.app_error", nil, "", http.StatusBadRequest)
}
......
......@@ -80,12 +80,12 @@ func TestIncomingWebhookIsValid(t *testing.T) {
t.Fatal(err)
}
o.Description = strings.Repeat("1", 129)
o.Description = strings.Repeat("1", 501)
if err := o.IsValid(); err == nil {
t.Fatal("should be invalid")
}
o.Description = strings.Repeat("1", 128)
o.Description = strings.Repeat("1", 500)
if err := o.IsValid(); err != nil {
t.Fatal(err)
}
......
......@@ -171,7 +171,7 @@ func (o *OutgoingWebhook) IsValid() *AppError {
return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.display_name.app_error", nil, "", http.StatusBadRequest)
}
if len(o.Description) > 128 {
if len(o.Description) > 500 {
return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.description.app_error", nil, "", http.StatusBadRequest)
}
......
......@@ -102,14 +102,14 @@ func TestOutgoingWebhookIsValid(t *testing.T) {
t.Fatal(err)
}
o.Description = strings.Repeat("1", 129)
o.Description = strings.Repeat("1", 501)
if err := o.IsValid(); err == nil {
t.Fatal("should be invalid")
}
o.Description = strings.Repeat("1", 128)
o.Description = strings.Repeat("1", 500)
if err := o.IsValid(); err != nil {
t.Fatal("should be invalid")
t.Fatal(err)
}
o.ContentType = strings.Repeat("1", 129)
......
......@@ -486,7 +486,8 @@ func UpgradeDatabaseToVersion52(sqlStore SqlStore) {
func UpgradeDatabaseToVersion53(sqlStore SqlStore) {
// TODO: Uncomment following condition when version 5.3.0 is released
// if shouldPerformUpgrade(sqlStore, VERSION_5_2_0, VERSION_5_3_0) {
sqlStore.AlterColumnTypeIfExists("OutgoingWebhooks", "Description", "varchar(500)", "varchar(500)")
sqlStore.AlterColumnTypeIfExists("IncomingWebhooks", "Description", "varchar(500)", "varchar(500)")
// saveSchemaVersion(sqlStore, VERSION_5_3_0)
// }
}
......@@ -47,7 +47,7 @@ func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface)
table.ColMap("ChannelId").SetMaxSize(26)
table.ColMap("TeamId").SetMaxSize(26)
table.ColMap("DisplayName").SetMaxSize(64)
table.ColMap("Description").SetMaxSize(128)
table.ColMap("Description").SetMaxSize(500)
tableo := db.AddTableWithName(model.OutgoingWebhook{}, "OutgoingWebhooks").SetKeys(false, "Id")
tableo.ColMap("Id").SetMaxSize(26)
......@@ -58,7 +58,7 @@ func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface)
tableo.ColMap("TriggerWords").SetMaxSize(1024)
tableo.ColMap("CallbackURLs").SetMaxSize(1024)
tableo.ColMap("DisplayName").SetMaxSize(64)
tableo.ColMap("Description").SetMaxSize(128)
tableo.ColMap("Description").SetMaxSize(500)
tableo.ColMap("ContentType").SetMaxSize(128)
tableo.ColMap("TriggerWhen").SetMaxSize(1)
tableo.ColMap("Username").SetMaxSize(64)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment