FEATURE: do no search for groups unless a term is specified

Do not allow `/u/search/users.json` to list any group matches unless a
specific `term` is specified in the API call.

Adding groups should always be done when an actual search term exists,
blank search is only supported for users within a topic
This commit is contained in:
Sam
2019-02-20 17:28:12 +11:00
parent 31ffa5f64e
commit 33269c4172
2 changed files with 32 additions and 10 deletions

View File

@ -867,6 +867,10 @@ class UsersController < ApplicationController
include_groups = params[:include_groups] == "true"
# blank term is only handy for in-topic search of users after @
# we do not want group results ever if term is blank
include_groups = groups = nil if term.blank?
if include_groups || groups
groups = Group.search_groups(term, groups: groups)
groups = groups.where(visibility_level: Group.visibility_levels[:public]) if include_groups