mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM 15187: Migrate "WebHook.DeleteOutgoing" to Sync by default (#10708)
* cherry commit for DeleteOutgoing and generate store mocks * go fmt the code
This commit is contained in:
committed by
Jesús Espino
parent
9fc05b5865
commit
caf0c0d375
@@ -833,7 +833,7 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
if result := <-a.Srv.Store.Webhook().DeleteOutgoing(hookId, model.GetMillis()); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
return nil
|
||||
return a.Srv.Store.Webhook().DeleteOutgoing(hookId, model.GetMillis())
|
||||
}
|
||||
|
||||
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 {
|
||||
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})
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoing", "store.sql_webhooks.delete_outgoing.app_error", nil, "id="+webhookId+", err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) *model.AppError {
|
||||
_, 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 {
|
||||
return 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 {
|
||||
|
||||
@@ -392,7 +392,7 @@ type WebhookStore interface {
|
||||
GetOutgoingList(offset, limit int) ([]*model.OutgoingWebhook, *model.AppError)
|
||||
GetOutgoingByChannel(channelId 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
|
||||
PermanentDeleteOutgoingByUser(userId string) 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
|
||||
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)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
|
||||
r0 = rf(webhookId, time)
|
||||
} else {
|
||||
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")
|
||||
}
|
||||
|
||||
if r2 := <-ss.Webhook().DeleteOutgoing(o1.Id, model.GetMillis()); r2.Err != nil {
|
||||
t.Fatal(r2.Err)
|
||||
if err := ss.Webhook().DeleteOutgoing(o1.Id, model.GetMillis()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := ss.Webhook().GetOutgoing(o1.Id); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user