MM 15187: Migrate "WebHook.DeleteOutgoing" to Sync by default (#10708)
* cherry commit for DeleteOutgoing and generate store mocks * go fmt the code
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
9fc05b5865
Коммит
caf0c0d375
@@ -833,7 +833,7 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, hook := range outgoingHooks {
|
for _, hook := range outgoingHooks {
|
||||||
if result := <-a.Srv.Store.Webhook().DeleteOutgoing(hook.Id, now); result.Err != nil {
|
if err := a.Srv.Store.Webhook().DeleteOutgoing(hook.Id, now); err != nil {
|
||||||
mlog.Error(fmt.Sprintf("Encountered error deleting outgoing webhook, id=%v", hook.Id))
|
mlog.Error(fmt.Sprintf("Encountered error deleting outgoing webhook, id=%v", hook.Id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -536,11 +536,7 @@ func (a *App) DeleteOutgoingWebhook(hookId string) *model.AppError {
|
|||||||
return model.NewAppError("DeleteOutgoingWebhook", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
return model.NewAppError("DeleteOutgoingWebhook", "api.outgoing_webhook.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Webhook().DeleteOutgoing(hookId, model.GetMillis()); result.Err != nil {
|
return a.Srv.Store.Webhook().DeleteOutgoing(hookId, model.GetMillis())
|
||||||
return result.Err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) RegenOutgoingWebhookToken(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) {
|
func (a *App) RegenOutgoingWebhookToken(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError) {
|
||||||
|
|||||||
@@ -282,13 +282,13 @@ func (s SqlWebhookStore) GetOutgoingByTeam(teamId string, offset, limit int) sto
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) store.StoreChannel {
|
func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
_, err := s.GetMaster().Exec("Update OutgoingWebhooks SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": webhookId})
|
||||||
_, err := s.GetMaster().Exec("Update OutgoingWebhooks 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.DeleteOutgoing", "store.sql_webhooks.delete_outgoing.app_error", nil, "id="+webhookId+", err="+err.Error(), http.StatusInternalServerError)
|
||||||
result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoing", "store.sql_webhooks.delete_outgoing.app_error", nil, "id="+webhookId+", err="+err.Error(), http.StatusInternalServerError)
|
}
|
||||||
}
|
|
||||||
})
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) store.StoreChannel {
|
func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) store.StoreChannel {
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ type WebhookStore interface {
|
|||||||
GetOutgoingList(offset, limit int) ([]*model.OutgoingWebhook, *model.AppError)
|
GetOutgoingList(offset, limit int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||||
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) *model.AppError
|
||||||
PermanentDeleteOutgoingByChannel(channelId string) *model.AppError
|
PermanentDeleteOutgoingByChannel(channelId string) *model.AppError
|
||||||
PermanentDeleteOutgoingByUser(userId string) StoreChannel
|
PermanentDeleteOutgoingByUser(userId string) StoreChannel
|
||||||
UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
|
UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
|
||||||
|
|||||||
@@ -74,15 +74,15 @@ func (_m *WebhookStore) DeleteIncoming(webhookId string, time int64) store.Store
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOutgoing provides a mock function with given fields: webhookId, time
|
// DeleteOutgoing provides a mock function with given fields: webhookId, time
|
||||||
func (_m *WebhookStore) DeleteOutgoing(webhookId string, time int64) store.StoreChannel {
|
func (_m *WebhookStore) DeleteOutgoing(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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -429,8 +429,8 @@ func testWebhookStoreDeleteOutgoing(t *testing.T, ss store.Store) {
|
|||||||
t.Fatal("invalid returned webhook")
|
t.Fatal("invalid returned webhook")
|
||||||
}
|
}
|
||||||
|
|
||||||
if r2 := <-ss.Webhook().DeleteOutgoing(o1.Id, model.GetMillis()); r2.Err != nil {
|
if err := ss.Webhook().DeleteOutgoing(o1.Id, model.GetMillis()); err != nil {
|
||||||
t.Fatal(r2.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := ss.Webhook().GetOutgoing(o1.Id); err == nil {
|
if _, err := ss.Webhook().GetOutgoing(o1.Id); err == nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user