mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user