mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrate "User.SearchWithoutTeam" to Sync by default (#11421)
This commit is contained in:
committed by
George Goldberg
parent
77ed6015fd
commit
89a41dc381
@@ -1770,11 +1770,10 @@ func (a *App) SearchUsersNotInTeam(notInTeamId string, term string, options *mod
|
||||
|
||||
func (a *App) SearchUsersWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
result := <-a.Srv.Store.User().SearchWithoutTeam(term, options)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
users, err := a.Srv.Store.User().SearchWithoutTeam(term, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
users := result.Data.([]*model.User)
|
||||
|
||||
for _, user := range users {
|
||||
a.SanitizeProfile(user, options.IsAdmin)
|
||||
|
||||
@@ -1233,10 +1233,9 @@ func (us SqlUserStore) Search(teamId string, term string, options *model.UserSea
|
||||
return result.Data.([]*model.User), nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
query := us.usersQuery.
|
||||
Where(`(
|
||||
func (us SqlUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
query := us.usersQuery.
|
||||
Where(`(
|
||||
SELECT
|
||||
COUNT(0)
|
||||
FROM
|
||||
@@ -1245,11 +1244,14 @@ func (us SqlUserStore) SearchWithoutTeam(term string, options *model.UserSearchO
|
||||
TeamMembers.UserId = u.Id
|
||||
AND TeamMembers.DeleteAt = 0
|
||||
) = 0`).
|
||||
OrderBy("u.Username ASC").
|
||||
Limit(uint64(options.Limit))
|
||||
OrderBy("u.Username ASC").
|
||||
Limit(uint64(options.Limit))
|
||||
|
||||
*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) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) store.StoreChannel {
|
||||
|
||||
@@ -292,7 +292,7 @@ type UserStore interface {
|
||||
SearchNotInTeam(notInTeamId 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
|
||||
SearchWithoutTeam(term string, options *model.UserSearchOptions) StoreChannel
|
||||
SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||
AnalyticsGetInactiveUsersCount() StoreChannel
|
||||
AnalyticsGetSystemAdminCount() StoreChannel
|
||||
GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) StoreChannel
|
||||
|
||||
@@ -856,19 +856,28 @@ func (_m *UserStore) SearchNotInTeam(notInTeamId string, term string, options *m
|
||||
}
|
||||
|
||||
// SearchWithoutTeam provides a mock function with given fields: term, options
|
||||
func (_m *UserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) store.StoreChannel {
|
||||
func (_m *UserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
ret := _m.Called(term, options)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, *model.UserSearchOptions) store.StoreChannel); ok {
|
||||
var r0 []*model.User
|
||||
if rf, ok := ret.Get(0).(func(string, *model.UserSearchOptions) []*model.User); ok {
|
||||
r0 = rf(term, options)
|
||||
} else {
|
||||
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, *model.UserSearchOptions) *model.AppError); ok {
|
||||
r1 = rf(term, options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: user, allowRoleUpdate
|
||||
|
||||
@@ -3091,12 +3091,12 @@ func testUserStoreSearchWithoutTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.Description, func(t *testing.T) {
|
||||
result := <-ss.User().SearchWithoutTeam(
|
||||
users, err := ss.User().SearchWithoutTeam(
|
||||
testCase.Term,
|
||||
testCase.Options,
|
||||
)
|
||||
require.Nil(t, result.Err)
|
||||
assertUsers(t, testCase.Expected, result.Data.([]*model.User))
|
||||
require.Nil(t, err)
|
||||
assertUsers(t, testCase.Expected, users)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user