[MM-15120] Migrate PermanentDeleteIncomingByChannel to Sync (#10677)
* Migrate PermanentDeleteIncomingByChannel to Sync * fix err
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
928ecba2d4
Коммит
cf5f5be0d8
@@ -1857,8 +1857,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
|
|||||||
return result.Err
|
return result.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Webhook().PermanentDeleteIncomingByChannel(channel.Id); result.Err != nil {
|
if err := a.Srv.Store.Webhook().PermanentDeleteIncomingByChannel(channel.Id); err != nil {
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.Srv.Store.Webhook().PermanentDeleteOutgoingByChannel(channel.Id); err != nil {
|
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 {
|
func (s SqlWebhookStore) PermanentDeleteIncomingByChannel(channelId string) *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
_, err := s.GetMaster().Exec("DELETE FROM IncomingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
|
||||||
_, err := s.GetMaster().Exec("DELETE FROM IncomingWebhooks WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
|
if err != nil {
|
||||||
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)
|
||||||
result.Err = 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) {
|
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)
|
UpdateIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, *model.AppError)
|
||||||
GetIncomingByChannel(channelId string) ([]*model.IncomingWebhook, *model.AppError)
|
GetIncomingByChannel(channelId string) ([]*model.IncomingWebhook, *model.AppError)
|
||||||
DeleteIncoming(webhookId string, time int64) StoreChannel
|
DeleteIncoming(webhookId string, time int64) StoreChannel
|
||||||
PermanentDeleteIncomingByChannel(channelId string) StoreChannel
|
PermanentDeleteIncomingByChannel(channelId string) *model.AppError
|
||||||
PermanentDeleteIncomingByUser(userId string) StoreChannel
|
PermanentDeleteIncomingByUser(userId string) StoreChannel
|
||||||
|
|
||||||
SaveOutgoing(webhook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
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
|
// 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)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,8 +229,8 @@ func testWebhookStoreDeleteIncomingByChannel(t *testing.T, ss store.Store) {
|
|||||||
t.Fatal("invalid returned webhook")
|
t.Fatal("invalid returned webhook")
|
||||||
}
|
}
|
||||||
|
|
||||||
if r2 := <-ss.Webhook().PermanentDeleteIncomingByChannel(o1.ChannelId); r2.Err != nil {
|
if err = ss.Webhook().PermanentDeleteIncomingByChannel(o1.ChannelId); err != nil {
|
||||||
t.Fatal(r2.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = ss.Webhook().GetIncoming(o1.Id, true); err == nil {
|
if _, err = ss.Webhook().GetIncoming(o1.Id, true); err == nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user