MM-15118: Migrates the "WebHook.DeleteIncoming" to Sync by default. (#10706)
* cherry commit for DeleteIncoming and generate store mocks * go fmt the code and fix go vet issue
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
13403b2cc1
Коммит
eb3923c835
@@ -826,7 +826,7 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
|||||||
|
|
||||||
now := model.GetMillis()
|
now := model.GetMillis()
|
||||||
for _, hook := range incomingHooks {
|
for _, hook := range incomingHooks {
|
||||||
if result := <-a.Srv.Store.Webhook().DeleteIncoming(hook.Id, now); result.Err != nil {
|
if err := a.Srv.Store.Webhook().DeleteIncoming(hook.Id, now); err != nil {
|
||||||
mlog.Error(fmt.Sprintf("Encountered error deleting incoming webhook, id=%v", hook.Id))
|
mlog.Error(fmt.Sprintf("Encountered error deleting incoming webhook, id=%v", hook.Id))
|
||||||
}
|
}
|
||||||
a.InvalidateCacheForWebhook(hook.Id)
|
a.InvalidateCacheForWebhook(hook.Id)
|
||||||
|
|||||||
@@ -360,8 +360,8 @@ func (a *App) DeleteIncomingWebhook(hookId string) *model.AppError {
|
|||||||
return model.NewAppError("DeleteIncomingWebhook", "api.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
return model.NewAppError("DeleteIncomingWebhook", "api.incoming_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Webhook().DeleteIncoming(hookId, model.GetMillis()); result.Err != nil {
|
if err := a.Srv.Store.Webhook().DeleteIncoming(hookId, model.GetMillis()); err != nil {
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
a.InvalidateCacheForWebhook(hookId)
|
a.InvalidateCacheForWebhook(hookId)
|
||||||
|
|||||||
@@ -142,15 +142,14 @@ func (s SqlWebhookStore) GetIncoming(id string, allowFromCache bool) (*model.Inc
|
|||||||
return &webhook, nil
|
return &webhook, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) store.StoreChannel {
|
func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
_, err := s.GetMaster().Exec("Update IncomingWebhooks SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": webhookId})
|
||||||
_, err := s.GetMaster().Exec("Update IncomingWebhooks SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": webhookId})
|
if err != nil {
|
||||||
if err != nil {
|
return model.NewAppError("SqlWebhookStore.DeleteIncoming", "store.sql_webhooks.delete_incoming.app_error", nil, "id="+webhookId+", err="+err.Error(), http.StatusInternalServerError)
|
||||||
result.Err = model.NewAppError("SqlWebhookStore.DeleteIncoming", "store.sql_webhooks.delete_incoming.app_error", nil, "id="+webhookId+", err="+err.Error(), http.StatusInternalServerError)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s.InvalidateWebhookCache(webhookId)
|
s.InvalidateWebhookCache(webhookId)
|
||||||
})
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) *model.AppError {
|
func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) *model.AppError {
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ type WebhookStore interface {
|
|||||||
GetIncomingByTeam(teamId string, offset, limit int) ([]*model.IncomingWebhook, *model.AppError)
|
GetIncomingByTeam(teamId string, offset, limit int) ([]*model.IncomingWebhook, *model.AppError)
|
||||||
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) *model.AppError
|
||||||
PermanentDeleteIncomingByChannel(channelId string) *model.AppError
|
PermanentDeleteIncomingByChannel(channelId string) *model.AppError
|
||||||
PermanentDeleteIncomingByUser(userId string) *model.AppError
|
PermanentDeleteIncomingByUser(userId string) *model.AppError
|
||||||
|
|
||||||
|
|||||||
@@ -58,15 +58,15 @@ func (_m *WebhookStore) ClearCaches() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteIncoming provides a mock function with given fields: webhookId, time
|
// DeleteIncoming provides a mock function with given fields: webhookId, time
|
||||||
func (_m *WebhookStore) DeleteIncoming(webhookId string, time int64) store.StoreChannel {
|
func (_m *WebhookStore) DeleteIncoming(webhookId string, time int64) *model.AppError {
|
||||||
ret := _m.Called(webhookId, time)
|
ret := _m.Called(webhookId, time)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.AppError
|
||||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
|
||||||
r0 = rf(webhookId, time)
|
r0 = rf(webhookId, time)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ func testWebhookStoreDeleteIncoming(t *testing.T, ss store.Store) {
|
|||||||
t.Fatal("invalid returned webhook")
|
t.Fatal("invalid returned webhook")
|
||||||
}
|
}
|
||||||
|
|
||||||
if r2 := <-ss.Webhook().DeleteIncoming(o1.Id, model.GetMillis()); r2.Err != nil {
|
if err = ss.Webhook().DeleteIncoming(o1.Id, model.GetMillis()); err != nil {
|
||||||
t.Fatal(r2.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
webhook, err = ss.Webhook().GetIncoming(o1.Id, true)
|
webhook, err = ss.Webhook().GetIncoming(o1.Id, true)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user