Migrate User.GetEtagForProfiles to sync by default (#11508)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
b832985f1d
Коммит
c0c93a1b09
@@ -498,7 +498,7 @@ func (a *App) GetUsersNotInTeamPage(teamId string, groupConstrained bool, page i
|
||||
}
|
||||
|
||||
func (a *App) GetUsersInTeamEtag(teamId string, restrictionsHash string) string {
|
||||
return fmt.Sprintf("%v.%v.%v.%v", (<-a.Srv.Store.User().GetEtagForProfiles(teamId)).Data.(string), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
return fmt.Sprintf("%v.%v.%v.%v", a.Srv.Store.User().GetEtagForProfiles(teamId), a.Config().PrivacySettings.ShowFullName, a.Config().PrivacySettings.ShowEmailAddress, restrictionsHash)
|
||||
}
|
||||
|
||||
func (a *App) GetUsersNotInTeamEtag(teamId string, restrictionsHash string) string {
|
||||
|
||||
@@ -488,15 +488,12 @@ func applyTeamGroupConstrainedFilter(query sq.SelectBuilder, teamId string) sq.S
|
||||
)`, teamId)
|
||||
}
|
||||
|
||||
func (s SqlUserStore) GetEtagForProfiles(teamId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users, TeamMembers WHERE TeamMembers.TeamId = :TeamId AND Users.Id = TeamMembers.UserId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"TeamId": teamId})
|
||||
if err != nil {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
} else {
|
||||
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
}
|
||||
})
|
||||
func (s SqlUserStore) GetEtagForProfiles(teamId string) string {
|
||||
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users, TeamMembers WHERE TeamMembers.TeamId = :TeamId AND Users.Id = TeamMembers.UserId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"TeamId": teamId})
|
||||
if err != nil {
|
||||
return fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
|
||||
}
|
||||
return fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetProfiles(options *model.UserGetOptions) store.StoreChannel {
|
||||
|
||||
@@ -281,7 +281,7 @@ type UserStore interface {
|
||||
GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) (*model.User, *model.AppError)
|
||||
VerifyEmail(userId, email string) (string, *model.AppError)
|
||||
GetEtagForAllProfiles() StoreChannel
|
||||
GetEtagForProfiles(teamId string) StoreChannel
|
||||
GetEtagForProfiles(teamId string) string
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
|
||||
GetSystemAdminProfiles() (map[string]*model.User, *model.AppError)
|
||||
PermanentDelete(userId string) *model.AppError
|
||||
|
||||
@@ -380,16 +380,14 @@ func (_m *UserStore) GetEtagForAllProfiles() store.StoreChannel {
|
||||
}
|
||||
|
||||
// GetEtagForProfiles provides a mock function with given fields: teamId
|
||||
func (_m *UserStore) GetEtagForProfiles(teamId string) store.StoreChannel {
|
||||
func (_m *UserStore) GetEtagForProfiles(teamId string) string {
|
||||
ret := _m.Called(teamId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(teamId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
|
||||
@@ -609,9 +609,7 @@ func testUserStoreGetProfiles(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("etag changes for all after user creation", func(t *testing.T) {
|
||||
result := <-ss.User().GetEtagForProfiles(teamId)
|
||||
require.Nil(t, result.Err)
|
||||
etag := result.Data.(string)
|
||||
etag := ss.User().GetEtagForProfiles(teamId)
|
||||
|
||||
uNew := &model.User{}
|
||||
uNew.Email = MakeEmail()
|
||||
@@ -619,10 +617,7 @@ func testUserStoreGetProfiles(t *testing.T, ss store.Store) {
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(uNew.Id)) }()
|
||||
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: uNew.Id}, -1))
|
||||
|
||||
result = <-ss.User().GetEtagForProfiles(teamId)
|
||||
require.Nil(t, result.Err)
|
||||
updatedEtag := result.Data.(string)
|
||||
|
||||
updatedEtag := ss.User().GetEtagForProfiles(teamId)
|
||||
require.NotEqual(t, etag, updatedEtag)
|
||||
})
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user