From ef11df753227f3082d5c2226c0e7525e14ed47c7 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Wed, 20 Jan 2016 08:44:05 -0600 Subject: PLT-7 adding loc db calls for webhooks table --- api/channel.go | 8 ++-- api/post.go | 2 +- api/user.go | 4 +- api/webhook.go | 20 +++++----- store/sql_webhook_store.go | 29 ++++++++------- store/sql_webhook_store_test.go | 81 +++++++++++++++++++++-------------------- store/store.go | 28 +++++++------- web/web.go | 2 +- 8 files changed, 88 insertions(+), 86 deletions(-) diff --git a/api/channel.go b/api/channel.go index 17a0f2031..f2880da5d 100644 --- a/api/channel.go +++ b/api/channel.go @@ -593,8 +593,8 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) { sc := Srv.Store.Channel().Get(id) scm := Srv.Store.Channel().GetMember(id, c.Session.UserId) uc := Srv.Store.User().Get(c.Session.UserId) - ihc := Srv.Store.Webhook().GetIncomingByChannel(id) - ohc := Srv.Store.Webhook().GetOutgoingByChannel(id) + ihc := Srv.Store.Webhook().GetIncomingByChannel(c.T, id) + ohc := Srv.Store.Webhook().GetOutgoingByChannel(c.T, id) if cresult := <-sc; cresult.Err != nil { c.Err = cresult.Err @@ -643,7 +643,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) { now := model.GetMillis() for _, hook := range incomingHooks { go func() { - if result := <-Srv.Store.Webhook().DeleteIncoming(hook.Id, now); result.Err != nil { + if result := <-Srv.Store.Webhook().DeleteIncoming(c.T, hook.Id, now); result.Err != nil { l4g.Error("Encountered error deleting incoming webhook, id=" + hook.Id) } }() @@ -651,7 +651,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) { for _, hook := range outgoingHooks { go func() { - if result := <-Srv.Store.Webhook().DeleteOutgoing(hook.Id, now); result.Err != nil { + if result := <-Srv.Store.Webhook().DeleteOutgoing(c.T, hook.Id, now); result.Err != nil { l4g.Error("Encountered error deleting outgoing webhook, id=" + hook.Id) } }() diff --git a/api/post.go b/api/post.go index 87678e9c6..17a3be8ba 100644 --- a/api/post.go +++ b/api/post.go @@ -310,7 +310,7 @@ func handleWebhookEventsAndForget(c *Context, post *model.Post, team *model.Team return } - hchan := Srv.Store.Webhook().GetOutgoingByTeam(c.Session.TeamId) + hchan := Srv.Store.Webhook().GetOutgoingByTeam(c.T, c.Session.TeamId) hooks := []*model.OutgoingWebhook{} diff --git a/api/user.go b/api/user.go index 001caae6c..66125d242 100644 --- a/api/user.go +++ b/api/user.go @@ -1444,11 +1444,11 @@ func PermanentDeleteUser(c *Context, user *model.User) *model.AppError { return result.Err } - if result := <-Srv.Store.Webhook().PermanentDeleteIncomingByUser(user.Id); result.Err != nil { + if result := <-Srv.Store.Webhook().PermanentDeleteIncomingByUser(c.T, user.Id); result.Err != nil { return result.Err } - if result := <-Srv.Store.Webhook().PermanentDeleteOutgoingByUser(user.Id); result.Err != nil { + if result := <-Srv.Store.Webhook().PermanentDeleteOutgoingByUser(c.T, user.Id); result.Err != nil { return result.Err } diff --git a/api/webhook.go b/api/webhook.go index a9a88b7b8..7c7d89866 100644 --- a/api/webhook.go +++ b/api/webhook.go @@ -62,7 +62,7 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { } } - if result := <-Srv.Store.Webhook().SaveIncoming(hook); result.Err != nil { + if result := <-Srv.Store.Webhook().SaveIncoming(c.T, hook); result.Err != nil { c.Err = result.Err return } else { @@ -89,7 +89,7 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - if result := <-Srv.Store.Webhook().GetIncoming(id); result.Err != nil { + if result := <-Srv.Store.Webhook().GetIncoming(c.T, id); result.Err != nil { c.Err = result.Err return } else { @@ -100,7 +100,7 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { } } - if err := (<-Srv.Store.Webhook().DeleteIncoming(id, model.GetMillis())).Err; err != nil { + if err := (<-Srv.Store.Webhook().DeleteIncoming(c.T, id, model.GetMillis())).Err; err != nil { c.Err = err return } @@ -116,7 +116,7 @@ func getIncomingHooks(c *Context, w http.ResponseWriter, r *http.Request) { return } - if result := <-Srv.Store.Webhook().GetIncomingByUser(c.Session.UserId); result.Err != nil { + if result := <-Srv.Store.Webhook().GetIncomingByUser(c.T, c.Session.UserId); result.Err != nil { c.Err = result.Err return } else { @@ -171,7 +171,7 @@ func createOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - if result := <-Srv.Store.Webhook().SaveOutgoing(hook); result.Err != nil { + if result := <-Srv.Store.Webhook().SaveOutgoing(c.T, hook); result.Err != nil { c.Err = result.Err return } else { @@ -188,7 +188,7 @@ func getOutgoingHooks(c *Context, w http.ResponseWriter, r *http.Request) { return } - if result := <-Srv.Store.Webhook().GetOutgoingByCreator(c.Session.UserId); result.Err != nil { + if result := <-Srv.Store.Webhook().GetOutgoingByCreator(c.T, c.Session.UserId); result.Err != nil { c.Err = result.Err return } else { @@ -214,7 +214,7 @@ func deleteOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - if result := <-Srv.Store.Webhook().GetOutgoing(id); result.Err != nil { + if result := <-Srv.Store.Webhook().GetOutgoing(c.T, id); result.Err != nil { c.Err = result.Err return } else { @@ -225,7 +225,7 @@ func deleteOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) { } } - if err := (<-Srv.Store.Webhook().DeleteOutgoing(id, model.GetMillis())).Err; err != nil { + if err := (<-Srv.Store.Webhook().DeleteOutgoing(c.T, id, model.GetMillis())).Err; err != nil { c.Err = err return } @@ -252,7 +252,7 @@ func regenOutgoingHookToken(c *Context, w http.ResponseWriter, r *http.Request) } var hook *model.OutgoingWebhook - if result := <-Srv.Store.Webhook().GetOutgoing(id); result.Err != nil { + if result := <-Srv.Store.Webhook().GetOutgoing(c.T, id); result.Err != nil { c.Err = result.Err return } else { @@ -267,7 +267,7 @@ func regenOutgoingHookToken(c *Context, w http.ResponseWriter, r *http.Request) hook.Token = model.NewId() - if result := <-Srv.Store.Webhook().UpdateOutgoing(hook); result.Err != nil { + if result := <-Srv.Store.Webhook().UpdateOutgoing(c.T, hook); result.Err != nil { c.Err = result.Err return } else { diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go index b7bf0615f..8b1e8136b 100644 --- a/store/sql_webhook_store.go +++ b/store/sql_webhook_store.go @@ -5,6 +5,7 @@ package store import ( "github.com/mattermost/platform/model" + goi18n "github.com/nicksnyder/go-i18n/i18n" ) type SqlWebhookStore struct { @@ -43,7 +44,7 @@ func (s SqlWebhookStore) CreateIndexesIfNotExists() { s.CreateIndexIfNotExists("idx_outgoing_webhook_team_id", "OutgoingWebhooks", "TeamId") } -func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) StoreChannel { +func (s SqlWebhookStore) SaveIncoming(T goi18n.TranslateFunc, webhook *model.IncomingWebhook) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -77,7 +78,7 @@ func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) StoreChann return storeChannel } -func (s SqlWebhookStore) GetIncoming(id string) StoreChannel { +func (s SqlWebhookStore) GetIncoming(T goi18n.TranslateFunc, id string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -98,7 +99,7 @@ func (s SqlWebhookStore) GetIncoming(id string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) StoreChannel { +func (s SqlWebhookStore) DeleteIncoming(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -116,7 +117,7 @@ func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) StoreChann return storeChannel } -func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) StoreChannel { +func (s SqlWebhookStore) PermanentDeleteIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -134,7 +135,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) StoreChann return storeChannel } -func (s SqlWebhookStore) GetIncomingByUser(userId string) StoreChannel { +func (s SqlWebhookStore) GetIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -155,7 +156,7 @@ func (s SqlWebhookStore) GetIncomingByUser(userId string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) GetIncomingByChannel(channelId string) StoreChannel { +func (s SqlWebhookStore) GetIncomingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -176,7 +177,7 @@ func (s SqlWebhookStore) GetIncomingByChannel(channelId string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel { +func (s SqlWebhookStore) SaveOutgoing(T goi18n.TranslateFunc, webhook *model.OutgoingWebhook) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -210,7 +211,7 @@ func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChann return storeChannel } -func (s SqlWebhookStore) GetOutgoing(id string) StoreChannel { +func (s SqlWebhookStore) GetOutgoing(T goi18n.TranslateFunc, id string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -231,7 +232,7 @@ func (s SqlWebhookStore) GetOutgoing(id string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) GetOutgoingByCreator(userId string) StoreChannel { +func (s SqlWebhookStore) GetOutgoingByCreator(T goi18n.TranslateFunc, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -252,7 +253,7 @@ func (s SqlWebhookStore) GetOutgoingByCreator(userId string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) GetOutgoingByChannel(channelId string) StoreChannel { +func (s SqlWebhookStore) GetOutgoingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -273,7 +274,7 @@ func (s SqlWebhookStore) GetOutgoingByChannel(channelId string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) GetOutgoingByTeam(teamId string) StoreChannel { +func (s SqlWebhookStore) GetOutgoingByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -294,7 +295,7 @@ func (s SqlWebhookStore) GetOutgoingByTeam(teamId string) StoreChannel { return storeChannel } -func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) StoreChannel { +func (s SqlWebhookStore) DeleteOutgoing(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -312,7 +313,7 @@ func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) StoreChann return storeChannel } -func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) StoreChannel { +func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(T goi18n.TranslateFunc, userId string) StoreChannel { storeChannel := make(StoreChannel) go func() { @@ -330,7 +331,7 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) StoreChann return storeChannel } -func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel { +func (s SqlWebhookStore) UpdateOutgoing(T goi18n.TranslateFunc, hook *model.OutgoingWebhook) StoreChannel { storeChannel := make(StoreChannel) go func() { diff --git a/store/sql_webhook_store_test.go b/store/sql_webhook_store_test.go index 1a9d5be3b..c5bd95af7 100644 --- a/store/sql_webhook_store_test.go +++ b/store/sql_webhook_store_test.go @@ -5,6 +5,7 @@ package store import ( "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" "testing" ) @@ -16,11 +17,11 @@ func TestWebhookStoreSaveIncoming(t *testing.T) { o1.UserId = model.NewId() o1.TeamId = model.NewId() - if err := (<-store.Webhook().SaveIncoming(&o1)).Err; err != nil { + if err := (<-store.Webhook().SaveIncoming(utils.T, &o1)).Err; err != nil { t.Fatal("couldn't save item", err) } - if err := (<-store.Webhook().SaveIncoming(&o1)).Err; err == nil { + if err := (<-store.Webhook().SaveIncoming(utils.T, &o1)).Err; err == nil { t.Fatal("shouldn't be able to update from save") } } @@ -33,9 +34,9 @@ func TestWebhookStoreGetIncoming(t *testing.T) { o1.UserId = model.NewId() o1.TeamId = model.NewId() - o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook) + o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook) - if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil { + if r1 := <-store.Webhook().GetIncoming(utils.T, o1.Id); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt { @@ -43,7 +44,7 @@ func TestWebhookStoreGetIncoming(t *testing.T) { } } - if err := (<-store.Webhook().GetIncoming("123")).Err; err == nil { + if err := (<-store.Webhook().GetIncoming(utils.T, "123")).Err; err == nil { t.Fatal("Missing id should have failed") } } @@ -56,9 +57,9 @@ func TestWebhookStoreGetIncomingByUser(t *testing.T) { o1.UserId = model.NewId() o1.TeamId = model.NewId() - o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook) + o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook) - if r1 := <-store.Webhook().GetIncomingByUser(o1.UserId); r1.Err != nil { + if r1 := <-store.Webhook().GetIncomingByUser(utils.T, o1.UserId); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.([]*model.IncomingWebhook)[0].CreateAt != o1.CreateAt { @@ -66,7 +67,7 @@ func TestWebhookStoreGetIncomingByUser(t *testing.T) { } } - if result := <-store.Webhook().GetIncomingByUser("123"); result.Err != nil { + if result := <-store.Webhook().GetIncomingByUser(utils.T, "123"); result.Err != nil { t.Fatal(result.Err) } else { if len(result.Data.([]*model.IncomingWebhook)) != 0 { @@ -83,9 +84,9 @@ func TestWebhookStoreDeleteIncoming(t *testing.T) { o1.UserId = model.NewId() o1.TeamId = model.NewId() - o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook) + o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook) - if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil { + if r1 := <-store.Webhook().GetIncoming(utils.T, o1.Id); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt { @@ -93,11 +94,11 @@ func TestWebhookStoreDeleteIncoming(t *testing.T) { } } - if r2 := <-store.Webhook().DeleteIncoming(o1.Id, model.GetMillis()); r2.Err != nil { + if r2 := <-store.Webhook().DeleteIncoming(utils.T, o1.Id, model.GetMillis()); r2.Err != nil { t.Fatal(r2.Err) } - if r3 := (<-store.Webhook().GetIncoming(o1.Id)); r3.Err == nil { + if r3 := (<-store.Webhook().GetIncoming(utils.T, o1.Id)); r3.Err == nil { t.Log(r3.Data) t.Fatal("Missing id should have failed") } @@ -111,9 +112,9 @@ func TestWebhookStoreDeleteIncomingByUser(t *testing.T) { o1.UserId = model.NewId() o1.TeamId = model.NewId() - o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook) + o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook) - if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil { + if r1 := <-store.Webhook().GetIncoming(utils.T, o1.Id); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt { @@ -121,11 +122,11 @@ func TestWebhookStoreDeleteIncomingByUser(t *testing.T) { } } - if r2 := <-store.Webhook().PermanentDeleteIncomingByUser(o1.UserId); r2.Err != nil { + if r2 := <-store.Webhook().PermanentDeleteIncomingByUser(utils.T, o1.UserId); r2.Err != nil { t.Fatal(r2.Err) } - if r3 := (<-store.Webhook().GetIncoming(o1.Id)); r3.Err == nil { + if r3 := (<-store.Webhook().GetIncoming(utils.T, o1.Id)); r3.Err == nil { t.Log(r3.Data) t.Fatal("Missing id should have failed") } @@ -140,11 +141,11 @@ func TestWebhookStoreSaveOutgoing(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - if err := (<-store.Webhook().SaveOutgoing(&o1)).Err; err != nil { + if err := (<-store.Webhook().SaveOutgoing(utils.T, &o1)).Err; err != nil { t.Fatal("couldn't save item", err) } - if err := (<-store.Webhook().SaveOutgoing(&o1)).Err; err == nil { + if err := (<-store.Webhook().SaveOutgoing(utils.T, &o1)).Err; err == nil { t.Fatal("shouldn't be able to update from save") } } @@ -158,9 +159,9 @@ func TestWebhookStoreGetOutgoing(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) - if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil { + if r1 := <-store.Webhook().GetOutgoing(utils.T, o1.Id); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt { @@ -168,7 +169,7 @@ func TestWebhookStoreGetOutgoing(t *testing.T) { } } - if err := (<-store.Webhook().GetOutgoing("123")).Err; err == nil { + if err := (<-store.Webhook().GetOutgoing(utils.T, "123")).Err; err == nil { t.Fatal("Missing id should have failed") } } @@ -182,9 +183,9 @@ func TestWebhookStoreGetOutgoingByChannel(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) - if r1 := <-store.Webhook().GetOutgoingByChannel(o1.ChannelId); r1.Err != nil { + if r1 := <-store.Webhook().GetOutgoingByChannel(utils.T, o1.ChannelId); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt { @@ -192,7 +193,7 @@ func TestWebhookStoreGetOutgoingByChannel(t *testing.T) { } } - if result := <-store.Webhook().GetOutgoingByChannel("123"); result.Err != nil { + if result := <-store.Webhook().GetOutgoingByChannel(utils.T, "123"); result.Err != nil { t.Fatal(result.Err) } else { if len(result.Data.([]*model.OutgoingWebhook)) != 0 { @@ -210,9 +211,9 @@ func TestWebhookStoreGetOutgoingByCreator(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) - if r1 := <-store.Webhook().GetOutgoingByCreator(o1.CreatorId); r1.Err != nil { + if r1 := <-store.Webhook().GetOutgoingByCreator(utils.T, o1.CreatorId); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt { @@ -220,7 +221,7 @@ func TestWebhookStoreGetOutgoingByCreator(t *testing.T) { } } - if result := <-store.Webhook().GetOutgoingByCreator("123"); result.Err != nil { + if result := <-store.Webhook().GetOutgoingByCreator(utils.T, "123"); result.Err != nil { t.Fatal(result.Err) } else { if len(result.Data.([]*model.OutgoingWebhook)) != 0 { @@ -238,9 +239,9 @@ func TestWebhookStoreGetOutgoingByTeam(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) - if r1 := <-store.Webhook().GetOutgoingByTeam(o1.TeamId); r1.Err != nil { + if r1 := <-store.Webhook().GetOutgoingByTeam(utils.T, o1.TeamId); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt { @@ -248,7 +249,7 @@ func TestWebhookStoreGetOutgoingByTeam(t *testing.T) { } } - if result := <-store.Webhook().GetOutgoingByTeam("123"); result.Err != nil { + if result := <-store.Webhook().GetOutgoingByTeam(utils.T, "123"); result.Err != nil { t.Fatal(result.Err) } else { if len(result.Data.([]*model.OutgoingWebhook)) != 0 { @@ -266,9 +267,9 @@ func TestWebhookStoreDeleteOutgoing(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) - if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil { + if r1 := <-store.Webhook().GetOutgoing(utils.T, o1.Id); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt { @@ -276,11 +277,11 @@ func TestWebhookStoreDeleteOutgoing(t *testing.T) { } } - if r2 := <-store.Webhook().DeleteOutgoing(o1.Id, model.GetMillis()); r2.Err != nil { + if r2 := <-store.Webhook().DeleteOutgoing(utils.T, o1.Id, model.GetMillis()); r2.Err != nil { t.Fatal(r2.Err) } - if r3 := (<-store.Webhook().GetOutgoing(o1.Id)); r3.Err == nil { + if r3 := (<-store.Webhook().GetOutgoing(utils.T, o1.Id)); r3.Err == nil { t.Log(r3.Data) t.Fatal("Missing id should have failed") } @@ -295,9 +296,9 @@ func TestWebhookStoreDeleteOutgoingByUser(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) - if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil { + if r1 := <-store.Webhook().GetOutgoing(utils.T, o1.Id); r1.Err != nil { t.Fatal(r1.Err) } else { if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt { @@ -305,11 +306,11 @@ func TestWebhookStoreDeleteOutgoingByUser(t *testing.T) { } } - if r2 := <-store.Webhook().PermanentDeleteOutgoingByUser(o1.CreatorId); r2.Err != nil { + if r2 := <-store.Webhook().PermanentDeleteOutgoingByUser(utils.T, o1.CreatorId); r2.Err != nil { t.Fatal(r2.Err) } - if r3 := (<-store.Webhook().GetOutgoing(o1.Id)); r3.Err == nil { + if r3 := (<-store.Webhook().GetOutgoing(utils.T, o1.Id)); r3.Err == nil { t.Log(r3.Data) t.Fatal("Missing id should have failed") } @@ -324,11 +325,11 @@ func TestWebhookStoreUpdateOutgoing(t *testing.T) { o1.TeamId = model.NewId() o1.CallbackURLs = []string{"http://nowhere.com/"} - o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook) o1.Token = model.NewId() - if r2 := <-store.Webhook().UpdateOutgoing(o1); r2.Err != nil { + if r2 := <-store.Webhook().UpdateOutgoing(utils.T, o1); r2.Err != nil { t.Fatal(r2.Err) } } diff --git a/store/store.go b/store/store.go index 58a9e0478..5b711fdc7 100644 --- a/store/store.go +++ b/store/store.go @@ -168,20 +168,20 @@ type SystemStore interface { } type WebhookStore interface { - SaveIncoming(webhook *model.IncomingWebhook) StoreChannel - GetIncoming(id string) StoreChannel - GetIncomingByUser(userId string) StoreChannel - GetIncomingByChannel(channelId string) StoreChannel - DeleteIncoming(webhookId string, time int64) StoreChannel - PermanentDeleteIncomingByUser(userId string) StoreChannel - SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel - GetOutgoing(id string) StoreChannel - GetOutgoingByCreator(userId string) StoreChannel - GetOutgoingByChannel(channelId string) StoreChannel - GetOutgoingByTeam(teamId string) StoreChannel - DeleteOutgoing(webhookId string, time int64) StoreChannel - PermanentDeleteOutgoingByUser(userId string) StoreChannel - UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel + SaveIncoming(T goi18n.TranslateFunc, webhook *model.IncomingWebhook) StoreChannel + GetIncoming(T goi18n.TranslateFunc, id string) StoreChannel + GetIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel + GetIncomingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel + DeleteIncoming(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel + PermanentDeleteIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel + SaveOutgoing(T goi18n.TranslateFunc, webhook *model.OutgoingWebhook) StoreChannel + GetOutgoing(T goi18n.TranslateFunc, id string) StoreChannel + GetOutgoingByCreator(T goi18n.TranslateFunc, userId string) StoreChannel + GetOutgoingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel + GetOutgoingByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel + DeleteOutgoing(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel + PermanentDeleteOutgoingByUser(T goi18n.TranslateFunc, userId string) StoreChannel + UpdateOutgoing(T goi18n.TranslateFunc, hook *model.OutgoingWebhook) StoreChannel } type PreferenceStore interface { diff --git a/web/web.go b/web/web.go index 31b9005e5..c7a7b8666 100644 --- a/web/web.go +++ b/web/web.go @@ -1022,7 +1022,7 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) id := params["id"] - hchan := api.Srv.Store.Webhook().GetIncoming(id) + hchan := api.Srv.Store.Webhook().GetIncoming(c.T, id) r.ParseForm() -- cgit v1.2.3-1-g7c22