diff --git a/app/channel.go b/app/channel.go index 771ab48e4b..d79b5a2cb9 100644 --- a/app/channel.go +++ b/app/channel.go @@ -1857,8 +1857,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError { return result.Err } - if result := <-a.Srv.Store.Webhook().PermanentDeleteIncomingByChannel(channel.Id); result.Err != nil { - return result.Err + if err := a.Srv.Store.Webhook().PermanentDeleteIncomingByChannel(channel.Id); err != nil { + return err } if err := a.Srv.Store.Webhook().PermanentDeleteOutgoingByChannel(channel.Id); err != nil { diff --git a/store/sqlstore/webhook_store.go b/store/sqlstore/webhook_store.go index e254a64ad7..95c71376a3 100644 --- a/store/sqlstore/webhook_store.go +++ b/store/sqlstore/webhook_store.go @@ -164,15 +164,15 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) store.Stor }) } -func (s SqlWebhookStore) PermanentDeleteIncomingByChannel(channelId string) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - _, err := s.GetMaster().Exec("DELETE FROM IncomingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) - if err != nil { - result.Err = model.NewAppError("SqlWebhookStore.DeleteIncomingByChannel", "store.sql_webhooks.permanent_delete_incoming_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError) - } +func (s SqlWebhookStore) PermanentDeleteIncomingByChannel(channelId string) *model.AppError { + _, err := s.GetMaster().Exec("DELETE FROM IncomingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) + if err != nil { + return model.NewAppError("SqlWebhookStore.DeleteIncomingByChannel", "store.sql_webhooks.permanent_delete_incoming_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError) + } - s.ClearCaches() - }) + s.ClearCaches() + + return nil } func (s SqlWebhookStore) GetIncomingList(offset, limit int) ([]*model.IncomingWebhook, *model.AppError) { diff --git a/store/store.go b/store/store.go index 04da8f331e..34bf9cf9f7 100644 --- a/store/store.go +++ b/store/store.go @@ -384,7 +384,7 @@ type WebhookStore interface { UpdateIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, *model.AppError) GetIncomingByChannel(channelId string) ([]*model.IncomingWebhook, *model.AppError) DeleteIncoming(webhookId string, time int64) StoreChannel - PermanentDeleteIncomingByChannel(channelId string) StoreChannel + PermanentDeleteIncomingByChannel(channelId string) *model.AppError PermanentDeleteIncomingByUser(userId string) StoreChannel SaveOutgoing(webhook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) diff --git a/store/storetest/mocks/WebhookStore.go b/store/storetest/mocks/WebhookStore.go index 845794f707..3c512d99e6 100644 --- a/store/storetest/mocks/WebhookStore.go +++ b/store/storetest/mocks/WebhookStore.go @@ -252,15 +252,15 @@ func (_m *WebhookStore) InvalidateWebhookCache(webhook string) { } // PermanentDeleteIncomingByChannel provides a mock function with given fields: channelId -func (_m *WebhookStore) PermanentDeleteIncomingByChannel(channelId string) store.StoreChannel { +func (_m *WebhookStore) PermanentDeleteIncomingByChannel(channelId string) *model.AppError { ret := _m.Called(channelId) - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok { + var r0 *model.AppError + if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { r0 = rf(channelId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).(*model.AppError) } } diff --git a/store/storetest/webhook_store.go b/store/storetest/webhook_store.go index cd1ebcb7de..85e4a6e418 100644 --- a/store/storetest/webhook_store.go +++ b/store/storetest/webhook_store.go @@ -229,8 +229,8 @@ func testWebhookStoreDeleteIncomingByChannel(t *testing.T, ss store.Store) { t.Fatal("invalid returned webhook") } - if r2 := <-ss.Webhook().PermanentDeleteIncomingByChannel(o1.ChannelId); r2.Err != nil { - t.Fatal(r2.Err) + if err = ss.Webhook().PermanentDeleteIncomingByChannel(o1.ChannelId); err != nil { + t.Fatal(err) } if _, err = ss.Webhook().GetIncoming(o1.Id, true); err == nil {