[MM-55304] Migrate "server/channels/store/searchlayer/user_layer.go" to use GenericStoreResult (#25351)

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
Paul-Stern
2023-11-14 12:18:10 +03:00
коммит произвёл GitHub
родитель 620acc029a
Коммит 5f8133254d

Просмотреть файл

@@ -115,17 +115,17 @@ func (s *SearchUserStore) autocompleteUsersInChannelByEngine(engine searchengine
return nil, err return nil, err
} }
uchan := make(chan store.StoreResult, 1) uchan := make(chan store.GenericStoreResult[[]*model.User], 1)
go func() { go func() {
users, nErr := s.UserStore.GetProfileByIds(context.Background(), uchanIds, nil, false) users, nErr := s.UserStore.GetProfileByIds(context.Background(), uchanIds, nil, false)
uchan <- store.StoreResult{Data: users, NErr: nErr} uchan <- store.GenericStoreResult[[]*model.User]{Data: users, NErr: nErr}
close(uchan) close(uchan)
}() }()
nuchan := make(chan store.StoreResult, 1) nuchan := make(chan store.GenericStoreResult[[]*model.User], 1)
go func() { go func() {
users, nErr := s.UserStore.GetProfileByIds(context.Background(), nuchanIds, nil, false) users, nErr := s.UserStore.GetProfileByIds(context.Background(), nuchanIds, nil, false)
nuchan <- store.StoreResult{Data: users, NErr: nErr} nuchan <- store.GenericStoreResult[[]*model.User]{Data: users, NErr: nErr}
close(nuchan) close(nuchan)
}() }()
@@ -135,15 +135,13 @@ func (s *SearchUserStore) autocompleteUsersInChannelByEngine(engine searchengine
if result.NErr != nil { if result.NErr != nil {
return nil, errors.Wrap(result.NErr, "failed to get user profiles by ids") return nil, errors.Wrap(result.NErr, "failed to get user profiles by ids")
} }
inUsers := result.Data.([]*model.User) autocomplete.InChannel = result.Data
autocomplete.InChannel = inUsers
result = <-nuchan result = <-nuchan
if result.NErr != nil { if result.NErr != nil {
return nil, errors.Wrap(result.NErr, "failed to get user profiles by ids") return nil, errors.Wrap(result.NErr, "failed to get user profiles by ids")
} }
outUsers := result.Data.([]*model.User) autocomplete.OutOfChannel = result.Data
autocomplete.OutOfChannel = outUsers
return autocomplete, nil return autocomplete, nil
} }