diff --git a/store/sqlstore/status_store.go b/store/sqlstore/status_store.go index 94e324c11f..3731a8d4ca 100644 --- a/store/sqlstore/status_store.go +++ b/store/sqlstore/status_store.go @@ -111,15 +111,12 @@ func (s SqlStatusStore) GetOnlineAway() store.StoreChannel { }) } -func (s SqlStatusStore) GetOnline() store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - var statuses []*model.Status - if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online", map[string]interface{}{"Online": model.STATUS_ONLINE}); err != nil { - result.Err = model.NewAppError("SqlStatusStore.GetOnline", "store.sql_status.get_online.app_error", nil, err.Error(), http.StatusInternalServerError) - } else { - result.Data = statuses - } - }) +func (s SqlStatusStore) GetOnline() ([]*model.Status, *model.AppError) { + var statuses []*model.Status + if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online", map[string]interface{}{"Online": model.STATUS_ONLINE}); err != nil { + return nil, model.NewAppError("SqlStatusStore.GetOnline", "store.sql_status.get_online.app_error", nil, err.Error(), http.StatusInternalServerError) + } + return statuses, nil } func (s SqlStatusStore) GetAllFromTeam(teamId string) store.StoreChannel { diff --git a/store/store.go b/store/store.go index 8133b2c8d4..951f0d2fb5 100644 --- a/store/store.go +++ b/store/store.go @@ -470,7 +470,7 @@ type StatusStore interface { Get(userId string) StoreChannel GetByIds(userIds []string) StoreChannel GetOnlineAway() StoreChannel - GetOnline() StoreChannel + GetOnline() ([]*model.Status, *model.AppError) GetAllFromTeam(teamId string) StoreChannel ResetAll() StoreChannel GetTotalActiveUsersCount() StoreChannel diff --git a/store/storetest/mocks/StatusStore.go b/store/storetest/mocks/StatusStore.go index 68ccdd4ecd..87cfda6361 100644 --- a/store/storetest/mocks/StatusStore.go +++ b/store/storetest/mocks/StatusStore.go @@ -62,19 +62,28 @@ func (_m *StatusStore) GetByIds(userIds []string) store.StoreChannel { } // GetOnline provides a mock function with given fields: -func (_m *StatusStore) GetOnline() store.StoreChannel { +func (_m *StatusStore) GetOnline() ([]*model.Status, *model.AppError) { ret := _m.Called() - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func() store.StoreChannel); ok { + var r0 []*model.Status + if rf, ok := ret.Get(0).(func() []*model.Status); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).([]*model.Status) } } - return r0 + var r1 *model.AppError + if rf, ok := ret.Get(1).(func() *model.AppError); ok { + r1 = rf() + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.AppError) + } + } + + return r0, r1 } // GetOnlineAway provides a mock function with given fields: diff --git a/store/storetest/status_store.go b/store/storetest/status_store.go index f9c55d3366..73b8c1a17f 100644 --- a/store/storetest/status_store.go +++ b/store/storetest/status_store.go @@ -58,10 +58,9 @@ func testStatusStore(t *testing.T, ss store.Store) { } } - if result := <-ss.Status().GetOnline(); result.Err != nil { - t.Fatal(result.Err) + if statuses, err := ss.Status().GetOnline(); err != nil { + t.Fatal(err) } else { - statuses := result.Data.([]*model.Status) for _, status := range statuses { if status.Status != model.STATUS_ONLINE { t.Fatal("should not have returned offline statuses")