mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrate User.GetEtagForAllProfiles to sync by default (#11509)
This commit is contained in:
committed by
Jesús Espino
parent
9839b46889
commit
cf695095d8
@@ -460,7 +460,7 @@ func (a *App) GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*mode
|
||||
}
|
||||
|
||||
func (a *App) GetUsersEtag(restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", (<-a.Srv.Store.User().GetEtagForAllProfiles()).Data.(string), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv.Store.User().GetEtagForAllProfiles(), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
|
||||
@@ -381,15 +381,12 @@ func (us SqlUserStore) GetAllAfter(limit int, afterId string) ([]*model.User, *m
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (s SqlUserStore) GetEtagForAllProfiles() store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users ORDER BY UpdateAt DESC LIMIT 1")
|
||||
if err != nil {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
} else {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
}
|
||||
})
|
||||
func (us SqlUserStore) GetEtagForAllProfiles() string {
|
||||
updateAt, err := us.GetReplica().SelectInt("SELECT UpdateAt FROM Users ORDER BY UpdateAt DESC LIMIT 1")
|
||||
if err != nil {
|
||||
return fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
}
|
||||
return fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
|
||||
|
||||
@@ -280,7 +280,7 @@ type UserStore interface {
|
||||
GetByUsername(username string) StoreChannel
|
||||
GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) (*model.User, *model.AppError)
|
||||
VerifyEmail(userId, email string) (string, *model.AppError)
|
||||
GetEtagForAllProfiles() StoreChannel
|
||||
GetEtagForAllProfiles() string
|
||||
GetEtagForProfiles(teamId string) string
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
|
||||
GetSystemAdminProfiles() (map[string]*model.User, *model.AppError)
|
||||
|
||||
@@ -373,16 +373,14 @@ func (_m *UserStore) GetChannelGroupUsers(channelID string) ([]*model.User, *mod
|
||||
}
|
||||
|
||||
// GetEtagForAllProfiles provides a mock function with given fields:
|
||||
func (_m *UserStore) GetEtagForAllProfiles() store.StoreChannel {
|
||||
func (_m *UserStore) GetEtagForAllProfiles() string {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
|
||||
@@ -457,19 +457,14 @@ func testUserStoreGetAllProfiles(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("etag changes for all after user creation", func(t *testing.T) {
|
||||
result := <-ss.User().GetEtagForAllProfiles()
|
||||
require.Nil(t, result.Err)
|
||||
etag := result.Data.(string)
|
||||
etag := ss.User().GetEtagForAllProfiles()
|
||||
|
||||
uNew := &model.User{}
|
||||
uNew.Email = MakeEmail()
|
||||
store.Must(ss.User().Save(uNew))
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(uNew.Id)) }()
|
||||
|
||||
result = <-ss.User().GetEtagForAllProfiles()
|
||||
require.Nil(t, result.Err)
|
||||
updatedEtag := result.Data.(string)
|
||||
|
||||
updatedEtag := ss.User().GetEtagForAllProfiles()
|
||||
require.NotEqual(t, etag, updatedEtag)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user