Migrate PermanentDeleteOutgoingByChannel to Sync (#10673)

Этот коммит содержится в:
tengis b
2019-04-23 21:40:41 +09:00
коммит произвёл Joram Wilander
родитель eaef1952b0
Коммит 0d1c69927f
5 изменённых файлов: 17 добавлений и 17 удалений

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

@@ -1856,8 +1856,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
return result.Err return result.Err
} }
if result := <-a.Srv.Store.Webhook().PermanentDeleteOutgoingByChannel(channel.Id); result.Err != nil { if err := a.Srv.Store.Webhook().PermanentDeleteOutgoingByChannel(channel.Id); err != nil {
return result.Err return err
} }
if result := <-a.Srv.Store.Channel().PermanentDelete(channel.Id); result.Err != nil { if result := <-a.Srv.Store.Channel().PermanentDelete(channel.Id); result.Err != nil {

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

@@ -305,15 +305,15 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) store.Stor
}) })
} }
func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) store.StoreChannel { func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) *model.AppError {
return store.Do(func(result *store.StoreResult) {
_, err := s.GetMaster().Exec("DELETE FROM OutgoingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) _, err := s.GetMaster().Exec("DELETE FROM OutgoingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
if err != nil { if err != nil {
result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoingByChannel", "store.sql_webhooks.permanent_delete_outgoing_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError) return model.NewAppError("SqlWebhookStore.DeleteOutgoingByChannel", "store.sql_webhooks.permanent_delete_outgoing_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError)
} }
s.ClearCaches() s.ClearCaches()
})
return nil
} }
func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) store.StoreChannel { func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) store.StoreChannel {

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

@@ -393,7 +393,7 @@ type WebhookStore interface {
GetOutgoingByChannel(channelId string, offset, limit int) StoreChannel GetOutgoingByChannel(channelId string, offset, limit int) StoreChannel
GetOutgoingByTeam(teamId string, offset, limit int) StoreChannel GetOutgoingByTeam(teamId string, offset, limit int) StoreChannel
DeleteOutgoing(webhookId string, time int64) StoreChannel DeleteOutgoing(webhookId string, time int64) StoreChannel
PermanentDeleteOutgoingByChannel(channelId string) StoreChannel PermanentDeleteOutgoingByChannel(channelId string) *model.AppError
PermanentDeleteOutgoingByUser(userId string) StoreChannel PermanentDeleteOutgoingByUser(userId string) StoreChannel
UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel

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

@@ -275,15 +275,15 @@ func (_m *WebhookStore) PermanentDeleteIncomingByUser(userId string) store.Store
} }
// PermanentDeleteOutgoingByChannel provides a mock function with given fields: channelId // PermanentDeleteOutgoingByChannel provides a mock function with given fields: channelId
func (_m *WebhookStore) PermanentDeleteOutgoingByChannel(channelId string) store.StoreChannel { func (_m *WebhookStore) PermanentDeleteOutgoingByChannel(channelId string) *model.AppError {
ret := _m.Called(channelId) ret := _m.Called(channelId)
var r0 store.StoreChannel var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok { if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
r0 = rf(channelId) r0 = rf(channelId)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel) r0 = ret.Get(0).(*model.AppError)
} }
} }

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

@@ -428,8 +428,8 @@ func testWebhookStoreDeleteOutgoingByChannel(t *testing.T, ss store.Store) {
} }
} }
if r2 := <-ss.Webhook().PermanentDeleteOutgoingByChannel(o1.ChannelId); r2.Err != nil { if err := ss.Webhook().PermanentDeleteOutgoingByChannel(o1.ChannelId); err != nil {
t.Fatal(r2.Err) t.Fatal(err)
} }
if r3 := (<-ss.Webhook().GetOutgoing(o1.Id)); r3.Err == nil { if r3 := (<-ss.Webhook().GetOutgoing(o1.Id)); r3.Err == nil {