mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-16520] Migrate "Status.ResetAll" to Sync by default (#11424)
* Updated ResetAll function to return object * Modified the defined interface * Changed the data type where ResetAll was referrenced * Refactored code Changed user's email * Fixed indentation
This commit is contained in:
committed by
George Goldberg
parent
ea8d441345
commit
a86b204105
@@ -234,8 +234,8 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = true })
|
||||
}
|
||||
|
||||
if result := <-s.Store.Status().ResetAll(); result.Err != nil {
|
||||
mlog.Error(fmt.Sprint("Error to reset the server status.", result.Err.Error()))
|
||||
if err := s.Store.Status().ResetAll(); err != nil {
|
||||
mlog.Error(fmt.Sprint("Error to reset the server status.", err.Error()))
|
||||
}
|
||||
|
||||
if s.joinCluster && s.Cluster != nil {
|
||||
|
||||
@@ -122,12 +122,11 @@ func (s SqlStatusStore) GetAllFromTeam(teamId string) ([]*model.Status, *model.A
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) ResetAll() store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := s.GetMaster().Exec("UPDATE Status SET Status = :Status WHERE Manual = false", map[string]interface{}{"Status": model.STATUS_OFFLINE}); err != nil {
|
||||
result.Err = model.NewAppError("SqlStatusStore.ResetAll", "store.sql_status.reset_all.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
func (s SqlStatusStore) ResetAll() *model.AppError {
|
||||
if _, err := s.GetMaster().Exec("UPDATE Status SET Status = :Status WHERE Manual = false", map[string]interface{}{"Status": model.STATUS_OFFLINE}); err != nil {
|
||||
return model.NewAppError("SqlStatusStore.ResetAll", "store.sql_status.reset_all.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
|
||||
@@ -473,7 +473,7 @@ type StatusStore interface {
|
||||
GetOnlineAway() ([]*model.Status, *model.AppError)
|
||||
GetOnline() ([]*model.Status, *model.AppError)
|
||||
GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError)
|
||||
ResetAll() StoreChannel
|
||||
ResetAll() *model.AppError
|
||||
GetTotalActiveUsersCount() (int64, *model.AppError)
|
||||
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
|
||||
}
|
||||
|
||||
@@ -153,15 +153,15 @@ func (_m *StatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
}
|
||||
|
||||
// ResetAll provides a mock function with given fields:
|
||||
func (_m *StatusStore) ResetAll() store.StoreChannel {
|
||||
func (_m *StatusStore) ResetAll() *model.AppError {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ func testStatusStore(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := (<-ss.Status().ResetAll()).Err; err != nil {
|
||||
if err := ss.Status().ResetAll(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user