[MM-16522] Migrate "Status.UpdateLastActivityAt" to Sync by default (#11444)
* [MM-16522] Migrate "Status.UpdateLastActivityAt" to Sync by default * Remove unused import
Этот коммит содержится в:
коммит произвёл
Dean Whillier
родитель
37b726b651
Коммит
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))
|
mlog.Error(fmt.Sprintf("Failed to save status for user_id=%v, err=%v", userId, err), mlog.String("user_id", userId))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
schan := a.Srv.Store.Status().UpdateLastActivityAt(status.UserId, status.LastActivityAt)
|
if err := a.Srv.Store.Status().UpdateLastActivityAt(status.UserId, status.LastActivityAt); err != nil {
|
||||||
if result := <-schan; result.Err != nil {
|
mlog.Error(fmt.Sprintf("Failed to save status for user_id=%v, err=%v", userId, err), mlog.String("user_id", userId))
|
||||||
mlog.Error(fmt.Sprintf("Failed to save status for user_id=%v, err=%v", userId, result.Err), mlog.String("user_id", userId))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,10 +134,10 @@ func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
|||||||
return count, nil
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) store.StoreChannel {
|
func (s SqlStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||||
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 {
|
||||||
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)
|
||||||
result.Err = 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)
|
GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError)
|
||||||
ResetAll() *model.AppError
|
ResetAll() *model.AppError
|
||||||
GetTotalActiveUsersCount() (int64, *model.AppError)
|
GetTotalActiveUsersCount() (int64, *model.AppError)
|
||||||
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
|
UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileInfoStore interface {
|
type FileInfoStore interface {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ package mocks
|
|||||||
|
|
||||||
import mock "github.com/stretchr/testify/mock"
|
import mock "github.com/stretchr/testify/mock"
|
||||||
import model "github.com/mattermost/mattermost-server/model"
|
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
|
// StatusStore is an autogenerated mock type for the StatusStore type
|
||||||
type StatusStore struct {
|
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
|
// 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)
|
ret := _m.Called(userId, lastActivityAt)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.AppError
|
||||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
|
||||||
r0 = rf(userId, lastActivityAt)
|
r0 = rf(userId, lastActivityAt)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
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 {
|
if err := ss.Status().UpdateLastActivityAt(status.UserId, 10); err != nil {
|
||||||
t.Fatal(result.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user