[MM-15120] Migrate PermanentDeleteIncomingByChannel to Sync (#10677)

* Migrate PermanentDeleteIncomingByChannel to Sync

* fix err
Этот коммит содержится в:
tengis b
2019-04-25 15:15:32 +09:00
коммит произвёл Jesús Espino
родитель 928ecba2d4
Коммит cf5f5be0d8
5 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@@ -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 {

Просмотреть файл

@@ -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) {

Просмотреть файл

@@ -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)

Просмотреть файл

@@ -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)
}
}

Просмотреть файл

@@ -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 {