implemented migration to sync (#11413)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
2193e43aac
Коммит
6ff393527e
15
app/user.go
15
app/user.go
@@ -1752,13 +1752,11 @@ func (a *App) SearchUsersInTeam(teamId, term string, options *model.UserSearchOp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !a.IsESAutocompletionEnabled() || err != nil {
|
if !a.IsESAutocompletionEnabled() || err != nil {
|
||||||
result := <-a.Srv.Store.User().Search(teamId, term, options)
|
users, err = a.Srv.Store.User().Search(teamId, term, options)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, result.Err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
users = result.Data.([]*model.User)
|
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
a.SanitizeProfile(user, options.IsAdmin)
|
a.SanitizeProfile(user, options.IsAdmin)
|
||||||
}
|
}
|
||||||
@@ -1936,12 +1934,11 @@ func (a *App) AutocompleteUsersInTeam(teamId string, term string, options *model
|
|||||||
|
|
||||||
if !a.IsESAutocompletionEnabled() || err != nil {
|
if !a.IsESAutocompletionEnabled() || err != nil {
|
||||||
autocomplete = &model.UserAutocompleteInTeam{}
|
autocomplete = &model.UserAutocompleteInTeam{}
|
||||||
result := <-a.Srv.Store.User().Search(teamId, term, options)
|
users, err := a.Srv.Store.User().Search(teamId, term, options)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, result.Err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
users := result.Data.([]*model.User)
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
a.SanitizeProfile(user, options.IsAdmin)
|
a.SanitizeProfile(user, options.IsAdmin)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1224,8 +1224,7 @@ func (us SqlUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (us SqlUserStore) Search(teamId string, term string, options *model.UserSearchOptions) store.StoreChannel {
|
func (us SqlUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
|
||||||
query := us.usersQuery.
|
query := us.usersQuery.
|
||||||
OrderBy("Username ASC").
|
OrderBy("Username ASC").
|
||||||
Limit(uint64(options.Limit))
|
Limit(uint64(options.Limit))
|
||||||
@@ -1233,9 +1232,11 @@ func (us SqlUserStore) Search(teamId string, term string, options *model.UserSea
|
|||||||
if teamId != "" {
|
if teamId != "" {
|
||||||
query = query.Join("TeamMembers tm ON ( tm.UserId = u.Id AND tm.DeleteAt = 0 AND tm.TeamId = ? )", teamId)
|
query = query.Join("TeamMembers tm ON ( tm.UserId = u.Id AND tm.DeleteAt = 0 AND tm.TeamId = ? )", teamId)
|
||||||
}
|
}
|
||||||
|
result := us.performSearch(query, term, options)
|
||||||
*result = us.performSearch(query, term, options)
|
if result.Err != nil {
|
||||||
})
|
return nil, result.Err
|
||||||
|
}
|
||||||
|
return result.Data.([]*model.User), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (us SqlUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) store.StoreChannel {
|
func (us SqlUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) store.StoreChannel {
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ type UserStore interface {
|
|||||||
GetAnyUnreadPostCountForChannel(userId string, channelId string) StoreChannel
|
GetAnyUnreadPostCountForChannel(userId string, channelId string) StoreChannel
|
||||||
GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) StoreChannel
|
GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) StoreChannel
|
||||||
GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||||
Search(teamId string, term string, options *model.UserSearchOptions) StoreChannel
|
Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||||
SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) StoreChannel
|
SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) StoreChannel
|
||||||
SearchInChannel(channelId string, term string, options *model.UserSearchOptions) StoreChannel
|
SearchInChannel(channelId string, term string, options *model.UserSearchOptions) StoreChannel
|
||||||
SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) StoreChannel
|
SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) StoreChannel
|
||||||
|
|||||||
@@ -749,19 +749,28 @@ func (_m *UserStore) Save(user *model.User) store.StoreChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search provides a mock function with given fields: teamId, term, options
|
// Search provides a mock function with given fields: teamId, term, options
|
||||||
func (_m *UserStore) Search(teamId string, term string, options *model.UserSearchOptions) store.StoreChannel {
|
func (_m *UserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||||
ret := _m.Called(teamId, term, options)
|
ret := _m.Called(teamId, term, options)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.User
|
||||||
if rf, ok := ret.Get(0).(func(string, string, *model.UserSearchOptions) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, string, *model.UserSearchOptions) []*model.User); ok {
|
||||||
r0 = rf(teamId, term, options)
|
r0 = rf(teamId, term, options)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).([]*model.User)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, string, *model.UserSearchOptions) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, term, options)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchInChannel provides a mock function with given fields: channelId, term, options
|
// SearchInChannel provides a mock function with given fields: channelId, term, options
|
||||||
|
|||||||
@@ -2412,9 +2412,9 @@ func testUserStoreSearch(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
result := <-ss.User().Search(testCase.TeamId, testCase.Term, testCase.Options)
|
users, err := ss.User().Search(testCase.TeamId, testCase.Term, testCase.Options)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, err)
|
||||||
assertUsersMatchInAnyOrder(t, testCase.Expected, result.Data.([]*model.User))
|
assertUsersMatchInAnyOrder(t, testCase.Expected, users)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2424,9 +2424,9 @@ func testUserStoreSearch(t *testing.T, ss store.Store) {
|
|||||||
Limit: model.USER_SEARCH_DEFAULT_LIMIT,
|
Limit: model.USER_SEARCH_DEFAULT_LIMIT,
|
||||||
}
|
}
|
||||||
|
|
||||||
r1 := <-ss.User().Search(tid, "", searchOptions)
|
users, err := ss.User().Search(tid, "", searchOptions)
|
||||||
require.Nil(t, r1.Err)
|
require.Nil(t, err)
|
||||||
assert.Len(t, r1.Data.([]*model.User), 4)
|
assert.Len(t, users, 4)
|
||||||
// Don't assert contents, since Postgres' default collation order is left up to
|
// Don't assert contents, since Postgres' default collation order is left up to
|
||||||
// the operating system, and jimbo1 might sort before or after jim-bo.
|
// the operating system, and jimbo1 might sort before or after jim-bo.
|
||||||
// assertUsers(t, []*model.User{u2, u1, u6, u5}, r1.Data.([]*model.User))
|
// assertUsers(t, []*model.User{u2, u1, u6, u5}, r1.Data.([]*model.User))
|
||||||
@@ -2438,9 +2438,9 @@ func testUserStoreSearch(t *testing.T, ss store.Store) {
|
|||||||
Limit: 2,
|
Limit: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
r1 := <-ss.User().Search(tid, "", searchOptions)
|
users, err := ss.User().Search(tid, "", searchOptions)
|
||||||
require.Nil(t, r1.Err)
|
require.Nil(t, err)
|
||||||
assert.Len(t, r1.Data.([]*model.User), 2)
|
assert.Len(t, users, 2)
|
||||||
// Don't assert contents, since Postgres' default collation order is left up to
|
// Don't assert contents, since Postgres' default collation order is left up to
|
||||||
// the operating system, and jimbo1 might sort before or after jim-bo.
|
// the operating system, and jimbo1 might sort before or after jim-bo.
|
||||||
// assertUsers(t, []*model.User{u2, u1, u6, u5}, r1.Data.([]*model.User))
|
// assertUsers(t, []*model.User{u2, u1, u6, u5}, r1.Data.([]*model.User))
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user