mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-15291: migrate commandStore.Delete to sync by default (#10742)
This commit is contained in:
@@ -525,9 +525,6 @@ func (a *App) DeleteCommand(commandId string) *model.AppError {
|
||||
if !*a.Config().ServiceSettings.EnableCommands {
|
||||
return model.NewAppError("DeleteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
result := <-a.Srv.Store.Command().Delete(commandId, model.GetMillis())
|
||||
if result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
return nil
|
||||
|
||||
return a.Srv.Store.Command().Delete(commandId, model.GetMillis())
|
||||
}
|
||||
|
||||
@@ -102,13 +102,13 @@ func (s SqlCommandStore) GetByTrigger(teamId string, trigger string) store.Store
|
||||
})
|
||||
}
|
||||
|
||||
func (s SqlCommandStore) Delete(commandId string, time int64) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
_, err := s.GetMaster().Exec("Update Commands SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": commandId})
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
func (s SqlCommandStore) Delete(commandId string, time int64) *model.AppError {
|
||||
_, err := s.GetMaster().Exec("Update Commands SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": commandId})
|
||||
if err != nil {
|
||||
return model.NewAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) *model.AppError {
|
||||
|
||||
@@ -414,7 +414,7 @@ type CommandStore interface {
|
||||
Get(id string) StoreChannel
|
||||
GetByTeam(teamId string) ([]*model.Command, *model.AppError)
|
||||
GetByTrigger(teamId string, trigger string) StoreChannel
|
||||
Delete(commandId string, time int64) StoreChannel
|
||||
Delete(commandId string, time int64) *model.AppError
|
||||
PermanentDeleteByTeam(teamId string) *model.AppError
|
||||
PermanentDeleteByUser(userId string) *model.AppError
|
||||
Update(hook *model.Command) (*model.Command, *model.AppError)
|
||||
|
||||
@@ -127,7 +127,10 @@ func testCommandStoreGetByTrigger(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
store.Must(ss.Command().Delete(o1.Id, model.GetMillis()))
|
||||
err = ss.Command().Delete(o1.Id, model.GetMillis())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if result := <-ss.Command().GetByTrigger(o1.TeamId, o1.Trigger); result.Err == nil {
|
||||
t.Fatal("no commands should have returned")
|
||||
@@ -155,8 +158,8 @@ func testCommandStoreDelete(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
if r2 := <-ss.Command().Delete(o1.Id, model.GetMillis()); r2.Err != nil {
|
||||
t.Fatal(r2.Err)
|
||||
if err := ss.Command().Delete(o1.Id, model.GetMillis()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if r3 := (<-ss.Command().Get(o1.Id)); r3.Err == nil {
|
||||
|
||||
@@ -37,15 +37,15 @@ func (_m *CommandStore) AnalyticsCommandCount(teamId string) (int64, *model.AppE
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: commandId, time
|
||||
func (_m *CommandStore) Delete(commandId string, time int64) store.StoreChannel {
|
||||
func (_m *CommandStore) Delete(commandId string, time int64) *model.AppError {
|
||||
ret := _m.Called(commandId, 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(commandId, time)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user