migrated to sync by default (#11488)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
7180002df8
Коммит
f8c9f881c9
14
app/user.go
14
app/user.go
@@ -1685,11 +1685,10 @@ func (a *App) SearchUsersInChannel(channelId string, term string, options *model
|
|||||||
|
|
||||||
func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||||
term = strings.TrimSpace(term)
|
term = strings.TrimSpace(term)
|
||||||
result := <-a.Srv.Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
users, err := a.Srv.Store.User().SearchNotInChannel(teamId, channelId, 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)
|
||||||
@@ -1851,7 +1850,12 @@ func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term s
|
|||||||
close(uchan)
|
close(uchan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
nuchan := a.Srv.Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
nuchan := make(chan store.StoreResult, 1)
|
||||||
|
go func() {
|
||||||
|
users, err := a.Srv.Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
||||||
|
nuchan <- store.StoreResult{Data: users, Err: err}
|
||||||
|
close(nuchan)
|
||||||
|
}()
|
||||||
|
|
||||||
result := <-uchan
|
result := <-uchan
|
||||||
if result.Err != nil {
|
if result.Err != nil {
|
||||||
|
|||||||
@@ -1273,24 +1273,26 @@ func (us SqlUserStore) SearchNotInTeam(notInTeamId string, term string, options
|
|||||||
return result.Data.([]*model.User), nil
|
return result.Data.([]*model.User), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (us SqlUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) store.StoreChannel {
|
func (us SqlUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query := us.usersQuery.
|
||||||
query := us.usersQuery.
|
LeftJoin("ChannelMembers cm ON ( cm.UserId = u.Id AND cm.ChannelId = ? )", channelId).
|
||||||
LeftJoin("ChannelMembers cm ON ( cm.UserId = u.Id AND cm.ChannelId = ? )", channelId).
|
Where("cm.UserId IS NULL").
|
||||||
Where("cm.UserId IS NULL").
|
OrderBy("Username ASC").
|
||||||
OrderBy("Username ASC").
|
Limit(uint64(options.Limit))
|
||||||
Limit(uint64(options.Limit))
|
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.GroupConstrained {
|
if options.GroupConstrained {
|
||||||
query = applyChannelGroupConstrainedFilter(query, channelId)
|
query = applyChannelGroupConstrainedFilter(query, channelId)
|
||||||
}
|
}
|
||||||
|
|
||||||
*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) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
func (us SqlUserStore) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ type UserStore interface {
|
|||||||
Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||||
SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||||
SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||||
SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) StoreChannel
|
SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||||
SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
|
||||||
AnalyticsGetInactiveUsersCount() (int64, *model.AppError)
|
AnalyticsGetInactiveUsersCount() (int64, *model.AppError)
|
||||||
AnalyticsGetSystemAdminCount() (int64, *model.AppError)
|
AnalyticsGetSystemAdminCount() (int64, *model.AppError)
|
||||||
|
|||||||
@@ -881,19 +881,28 @@ func (_m *UserStore) SearchInChannel(channelId string, term string, options *mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SearchNotInChannel provides a mock function with given fields: teamId, channelId, term, options
|
// SearchNotInChannel provides a mock function with given fields: teamId, channelId, term, options
|
||||||
func (_m *UserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) store.StoreChannel {
|
func (_m *UserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||||
ret := _m.Called(teamId, channelId, term, options)
|
ret := _m.Called(teamId, channelId, term, options)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.User
|
||||||
if rf, ok := ret.Get(0).(func(string, string, string, *model.UserSearchOptions) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, string, string, *model.UserSearchOptions) []*model.User); ok {
|
||||||
r0 = rf(teamId, channelId, term, options)
|
r0 = rf(teamId, channelId, 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, string, *model.UserSearchOptions) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, channelId, term, options)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchNotInTeam provides a mock function with given fields: notInTeamId, term, options
|
// SearchNotInTeam provides a mock function with given fields: notInTeamId, term, options
|
||||||
|
|||||||
@@ -2669,14 +2669,14 @@ func testUserStoreSearchNotInChannel(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().SearchNotInChannel(
|
users, err := ss.User().SearchNotInChannel(
|
||||||
testCase.TeamId,
|
testCase.TeamId,
|
||||||
testCase.ChannelId,
|
testCase.ChannelId,
|
||||||
testCase.Term,
|
testCase.Term,
|
||||||
testCase.Options,
|
testCase.Options,
|
||||||
)
|
)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, err)
|
||||||
assertUsers(t, testCase.Expected, result.Data.([]*model.User))
|
assertUsers(t, testCase.Expected, users)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user