[MM-13500] Adds channel /search_group endpoint (#10805)

* [MM-13500] Adds channel /search_group endpoint

* Add LIMIT to the queries

* Fix i18n extract

* Fix tests

* Add a new endpoint to get profiles by group channel ids

* Rebase fix
Этот коммит содержится в:
Miguel de la Cruz
2019-06-22 00:14:21 +01:00
коммит произвёл GitHub
родитель 604e247135
Коммит 9e9b008f3d
15 изменённых файлов: 655 добавлений и 5 удалений

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

@@ -1801,6 +1801,18 @@ func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *m
return a.Srv.Store.Channel().SearchInTeam(teamId, term, includeDeleted)
}
func (a *App) SearchGroupChannels(userId, term string) (*model.ChannelList, *model.AppError) {
if term == "" {
return &model.ChannelList{}, nil
}
channelList, err := a.Srv.Store.Channel().SearchGroupChannels(userId, term)
if err != nil {
return nil, err
}
return channelList, nil
}
func (a *App) SearchChannelsUserNotIn(teamId string, userId string, term string) (*model.ChannelList, *model.AppError) {
term = strings.TrimSpace(term)
return a.Srv.Store.Channel().SearchMore(userId, teamId, term)

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

@@ -637,6 +637,18 @@ func (a *App) GetUsersByIds(userIds []string, asAdmin bool, viewRestrictions *mo
return a.sanitizeProfiles(result.Data.([]*model.User), asAdmin), nil
}
func (a *App) GetUsersByGroupChannelIds(channelIds []string, asAdmin bool) (map[string][]*model.User, *model.AppError) {
usersByChannelId, err := a.Srv.Store.User().GetProfileByGroupChannelIdsForUser(a.Session.UserId, channelIds)
if err != nil {
return nil, err
}
for channelId, userList := range usersByChannelId {
usersByChannelId[channelId] = a.sanitizeProfiles(userList, asAdmin)
}
return usersByChannelId, nil
}
func (a *App) GetUsersByUsernames(usernames []string, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
result := <-a.Srv.Store.User().GetProfilesByUsernames(usernames, viewRestrictions)
if result.Err != nil {