summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorPradeep Murugesan <pradeepmurugesan@outlook.com>2018-07-25 14:31:41 +0200
committerJesse Hallam <jesse.hallam@gmail.com>2018-07-25 08:31:41 -0400
commitb3c2ecd9b9209413e7272b2fcd7bd3d04f2f85f4 (patch)
tree6c4ebe9d5bd20b2923e85b0586c7929682d392c5 /store
parentb89ccca929e67ddd2a8f7ac2e952532bf615a51b (diff)
downloadchat-b3c2ecd9b9209413e7272b2fcd7bd3d04f2f85f4.tar.gz
chat-b3c2ecd9b9209413e7272b2fcd7bd3d04f2f85f4.tar.bz2
chat-b3c2ecd9b9209413e7272b2fcd7bd3d04f2f85f4.zip
added the custom icon and username for the outgoing webhook and its response (#9141)
* 8272 added the username and icon as part of the model and persisted the same * 8272 added the custome icon and name when set to the web hook response * 8272 changed the infinte loop to timeout after 5 seconds * 8272 fixed review comments
Diffstat (limited to 'store')
-rw-r--r--store/sqlstore/upgrade.go3
-rw-r--r--store/sqlstore/webhook_store.go2
-rw-r--r--store/storetest/webhook_store.go7
3 files changed, 11 insertions, 1 deletions
diff --git a/store/sqlstore/upgrade.go b/store/sqlstore/upgrade.go
index 8ea44371c..b2299b223 100644
--- a/store/sqlstore/upgrade.go
+++ b/store/sqlstore/upgrade.go
@@ -476,7 +476,8 @@ func UpgradeDatabaseToVersion51(sqlStore SqlStore) {
func UpgradeDatabaseToVersion52(sqlStore SqlStore) {
// TODO: Uncomment following condition when version 5.2.0 is released
// if shouldPerformUpgrade(sqlStore, VERSION_5_1_0, VERSION_5_2_0) {
-
+ sqlStore.CreateColumnIfNotExists("OutgoingWebhooks", "Username", "varchar(64)", "varchar(64)", "")
+ sqlStore.CreateColumnIfNotExists("OutgoingWebhooks", "IconURL", "varchar(1024)", "varchar(1024)", "")
// saveSchemaVersion(sqlStore, VERSION_5_2_0)
// }
}
diff --git a/store/sqlstore/webhook_store.go b/store/sqlstore/webhook_store.go
index 45ad90e52..f3c572aaf 100644
--- a/store/sqlstore/webhook_store.go
+++ b/store/sqlstore/webhook_store.go
@@ -61,6 +61,8 @@ func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface)
tableo.ColMap("Description").SetMaxSize(128)
tableo.ColMap("ContentType").SetMaxSize(128)
tableo.ColMap("TriggerWhen").SetMaxSize(1)
+ tableo.ColMap("Username").SetMaxSize(64)
+ tableo.ColMap("IconURL").SetMaxSize(1024)
}
return s
diff --git a/store/storetest/webhook_store.go b/store/storetest/webhook_store.go
index 7f87ec29d..2dfa2ae53 100644
--- a/store/storetest/webhook_store.go
+++ b/store/storetest/webhook_store.go
@@ -239,6 +239,8 @@ func testWebhookStoreSaveOutgoing(t *testing.T, ss store.Store) {
o1.CreatorId = model.NewId()
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
+ o1.Username = "test-user-name"
+ o1.IconURL = "http://nowhere.com/icon"
if err := (<-ss.Webhook().SaveOutgoing(&o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
@@ -255,6 +257,8 @@ func testWebhookStoreGetOutgoing(t *testing.T, ss store.Store) {
o1.CreatorId = model.NewId()
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
+ o1.Username = "test-user-name"
+ o1.IconURL = "http://nowhere.com/icon"
o1 = (<-ss.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
@@ -461,10 +465,13 @@ func testWebhookStoreUpdateOutgoing(t *testing.T, ss store.Store) {
o1.CreatorId = model.NewId()
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
+ o1.Username = "test-user-name"
+ o1.IconURL = "http://nowhere.com/icon"
o1 = (<-ss.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
o1.Token = model.NewId()
+ o1.Username = "another-test-user-name"
if r2 := <-ss.Webhook().UpdateOutgoing(o1); r2.Err != nil {
t.Fatal(r2.Err)