diff --git a/store/sqlstore/status_store.go b/store/sqlstore/status_store.go index de81e58bdc..f41dc15173 100644 --- a/store/sqlstore/status_store.go +++ b/store/sqlstore/status_store.go @@ -96,15 +96,12 @@ func (s SqlStatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppE return statuses, nil } -func (s SqlStatusStore) GetOnlineAway() 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 OR Status = :Away LIMIT 300", map[string]interface{}{"Online": model.STATUS_ONLINE, "Away": model.STATUS_AWAY}); err != nil { - result.Err = model.NewAppError("SqlStatusStore.GetOnlineAway", "store.sql_status.get_online_away.app_error", nil, err.Error(), http.StatusInternalServerError) - } else { - result.Data = statuses - } - }) +func (s SqlStatusStore) GetOnlineAway() ([]*model.Status, *model.AppError) { + var statuses []*model.Status + if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online OR Status = :Away LIMIT 300", map[string]interface{}{"Online": model.STATUS_ONLINE, "Away": model.STATUS_AWAY}); err != nil { + return nil, model.NewAppError("SqlStatusStore.GetOnlineAway", "store.sql_status.get_online_away.app_error", nil, err.Error(), http.StatusInternalServerError) + } + return statuses, nil } func (s SqlStatusStore) GetOnline() ([]*model.Status, *model.AppError) { diff --git a/store/store.go b/store/store.go index 8b6d866210..cd9041c322 100644 --- a/store/store.go +++ b/store/store.go @@ -470,7 +470,7 @@ type StatusStore interface { SaveOrUpdate(status *model.Status) *model.AppError Get(userId string) StoreChannel GetByIds(userIds []string) ([]*model.Status, *model.AppError) - GetOnlineAway() StoreChannel + GetOnlineAway() ([]*model.Status, *model.AppError) GetOnline() ([]*model.Status, *model.AppError) GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError) ResetAll() StoreChannel diff --git a/store/storetest/mocks/StatusStore.go b/store/storetest/mocks/StatusStore.go index f84b9ceda0..6cf05a2b41 100644 --- a/store/storetest/mocks/StatusStore.go +++ b/store/storetest/mocks/StatusStore.go @@ -105,19 +105,28 @@ func (_m *StatusStore) GetOnline() ([]*model.Status, *model.AppError) { } // GetOnlineAway provides a mock function with given fields: -func (_m *StatusStore) GetOnlineAway() store.StoreChannel { +func (_m *StatusStore) GetOnlineAway() ([]*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 } // GetTotalActiveUsersCount provides a mock function with given fields: diff --git a/store/storetest/status_store.go b/store/storetest/status_store.go index 74f59e52e4..bfd5a03082 100644 --- a/store/storetest/status_store.go +++ b/store/storetest/status_store.go @@ -36,10 +36,9 @@ func testStatusStore(t *testing.T, ss store.Store) { status3 := &model.Status{UserId: model.NewId(), Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""} require.Nil(t, ss.Status().SaveOrUpdate(status3)) - if result := <-ss.Status().GetOnlineAway(); result.Err != nil { - t.Fatal(result.Err) + if statuses, err := ss.Status().GetOnlineAway(); err != nil { + t.Fatal(err) } else { - statuses := result.Data.([]*model.Status) for _, status := range statuses { if status.Status == model.STATUS_OFFLINE { t.Fatal("should not have returned offline statuses")