From 23e64ec9aa2fd245a7e3b2faf5973433d8080c03 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 14 Sep 2017 11:47:34 -0400 Subject: Invalidate webhook cache after updating webhook (#7430) --- api4/webhook_test.go | 5 +++++ app/webhook.go | 1 + 2 files changed, 6 insertions(+) diff --git a/api4/webhook_test.go b/api4/webhook_test.go index aa263d47f..f85761026 100644 --- a/api4/webhook_test.go +++ b/api4/webhook_test.go @@ -8,6 +8,8 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/assert" + "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -503,6 +505,9 @@ func TestUpdateIncomingHook(t *testing.T) { } else { t.Fatal("should not be nil") } + + //updatedHook, _ = th.App.GetIncomingWebhook(createdHook.Id) + assert.Equal(t, updatedHook.ChannelId, createdHook.ChannelId) }) t.Run("RetainCreateAt", func(t *testing.T) { diff --git a/app/webhook.go b/app/webhook.go index 0dfbde7ac..61b8b4d1a 100644 --- a/app/webhook.go +++ b/app/webhook.go @@ -219,6 +219,7 @@ func (a *App) UpdateIncomingWebhook(oldHook, updatedHook *model.IncomingWebhook) if result := <-a.Srv.Store.Webhook().UpdateIncoming(updatedHook); result.Err != nil { return nil, result.Err } else { + a.InvalidateCacheForWebhook(oldHook.Id) return result.Data.(*model.IncomingWebhook), nil } } -- cgit v1.2.3-1-g7c22