mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-16522] Migrate "Status.UpdateLastActivityAt" to Sync by default (#11444)
* [MM-16522] Migrate "Status.UpdateLastActivityAt" to Sync by default * Remove unused import
This commit is contained in:
committed by
Dean Whillier
parent
37b726b651
commit
7180002df8
@@ -218,9 +218,8 @@ func (a *App) SetStatusOnline(userId string, manual bool) {
|
||||
mlog.Error(fmt.Sprintf("Failed to save status for user_id=%v, err=%v", userId, err), mlog.String("user_id", userId))
|
||||
}
|
||||
} else {
|
||||
schan := a.Srv.Store.Status().UpdateLastActivityAt(status.UserId, status.LastActivityAt)
|
||||
if result := <-schan; result.Err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to save status for user_id=%v, err=%v", userId, result.Err), mlog.String("user_id", userId))
|
||||
if err := a.Srv.Store.Status().UpdateLastActivityAt(status.UserId, status.LastActivityAt); err != nil {
|
||||
mlog.Error(fmt.Sprintf("Failed to save status for user_id=%v, err=%v", userId, err), mlog.String("user_id", userId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,10 +134,10 @@ func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := s.GetMaster().Exec("UPDATE Status SET LastActivityAt = :Time WHERE UserId = :UserId", map[string]interface{}{"UserId": userId, "Time": lastActivityAt}); err != nil {
|
||||
result.Err = model.NewAppError("SqlStatusStore.UpdateLastActivityAt", "store.sql_status.update_last_activity_at.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
func (s SqlStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
if _, err := s.GetMaster().Exec("UPDATE Status SET LastActivityAt = :Time WHERE UserId = :UserId", map[string]interface{}{"UserId": userId, "Time": lastActivityAt}); err != nil {
|
||||
return model.NewAppError("SqlStatusStore.UpdateLastActivityAt", "store.sql_status.update_last_activity_at.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ type StatusStore interface {
|
||||
GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError)
|
||||
ResetAll() *model.AppError
|
||||
GetTotalActiveUsersCount() (int64, *model.AppError)
|
||||
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
|
||||
UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError
|
||||
}
|
||||
|
||||
type FileInfoStore interface {
|
||||
|
||||
@@ -6,7 +6,6 @@ package mocks
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
import model "github.com/mattermost/mattermost-server/model"
|
||||
import store "github.com/mattermost/mattermost-server/store"
|
||||
|
||||
// StatusStore is an autogenerated mock type for the StatusStore type
|
||||
type StatusStore struct {
|
||||
@@ -194,15 +193,15 @@ func (_m *StatusStore) SaveOrUpdate(status *model.Status) *model.AppError {
|
||||
}
|
||||
|
||||
// UpdateLastActivityAt provides a mock function with given fields: userId, lastActivityAt
|
||||
func (_m *StatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) store.StoreChannel {
|
||||
func (_m *StatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
ret := _m.Called(userId, lastActivityAt)
|
||||
|
||||
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(userId, lastActivityAt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ func testStatusStore(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-ss.Status().UpdateLastActivityAt(status.UserId, 10); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
if err := ss.Status().UpdateLastActivityAt(status.UserId, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user