From ea26c72dad3bc1a2ccb020310b635bd6484a1b15 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 2 Dec 2016 12:24:22 -0500 Subject: PLT-4710 User search now obeys privacy settings (#4673) * Consider privacy settings in user search * Add sysadmin as exception to privacy settings for user search --- store/sql_user_store.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'store/sql_user_store.go') diff --git a/store/sql_user_store.go b/store/sql_user_store.go index b09b479a9..1eea1fdc2 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -15,14 +15,18 @@ import ( ) const ( - MISSING_ACCOUNT_ERROR = "store.sql_user.missing_account.const" - MISSING_AUTH_ACCOUNT_ERROR = "store.sql_user.get_by_auth.missing_account.app_error" - PROFILES_IN_CHANNEL_CACHE_SIZE = 5000 - PROFILES_IN_CHANNEL_CACHE_SEC = 900 // 15 mins - USER_SEARCH_OPTION_NAMES_ONLY = "names_only" - USER_SEARCH_OPTION_ALLOW_INACTIVE = "allow_inactive" - USER_SEARCH_TYPE_NAMES = "Username, FirstName, LastName, Nickname" - USER_SEARCH_TYPE_ALL = "Username, FirstName, LastName, Nickname, Email" + MISSING_ACCOUNT_ERROR = "store.sql_user.missing_account.const" + MISSING_AUTH_ACCOUNT_ERROR = "store.sql_user.get_by_auth.missing_account.app_error" + PROFILES_IN_CHANNEL_CACHE_SIZE = 5000 + PROFILES_IN_CHANNEL_CACHE_SEC = 900 // 15 mins + USER_SEARCH_OPTION_NAMES_ONLY = "names_only" + USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME = "names_only_no_full_name" + USER_SEARCH_OPTION_ALL_NO_FULL_NAME = "all_no_full_name" + USER_SEARCH_OPTION_ALLOW_INACTIVE = "allow_inactive" + USER_SEARCH_TYPE_NAMES_NO_FULL_NAME = "Username, Nickname" + USER_SEARCH_TYPE_NAMES = "Username, FirstName, LastName, Nickname" + USER_SEARCH_TYPE_ALL_NO_FULL_NAME = "Username, Nickname, Email" + USER_SEARCH_TYPE_ALL = "Username, FirstName, LastName, Nickname, Email" ) type SqlUserStore struct { @@ -62,7 +66,9 @@ func (us SqlUserStore) CreateIndexesIfNotExists() { us.CreateIndexIfNotExists("idx_users_delete_at", "Users", "DeleteAt") us.CreateFullTextIndexIfNotExists("idx_users_all_txt", "Users", USER_SEARCH_TYPE_ALL) + us.CreateFullTextIndexIfNotExists("idx_users_all_no_full_name_txt", "Users", USER_SEARCH_TYPE_ALL_NO_FULL_NAME) us.CreateFullTextIndexIfNotExists("idx_users_names_txt", "Users", USER_SEARCH_TYPE_NAMES) + us.CreateFullTextIndexIfNotExists("idx_users_names_no_full_name_txt", "Users", USER_SEARCH_TYPE_NAMES_NO_FULL_NAME) } func (us SqlUserStore) Save(user *model.User) StoreChannel { @@ -1241,6 +1247,10 @@ func (us SqlUserStore) performSearch(searchQuery string, term string, options ma searchType := USER_SEARCH_TYPE_ALL if ok := options[USER_SEARCH_OPTION_NAMES_ONLY]; ok { searchType = USER_SEARCH_TYPE_NAMES + } else if ok = options[USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME]; ok { + searchType = USER_SEARCH_TYPE_NAMES_NO_FULL_NAME + } else if ok = options[USER_SEARCH_OPTION_ALL_NO_FULL_NAME]; ok { + searchType = USER_SEARCH_TYPE_ALL_NO_FULL_NAME } if ok := options[USER_SEARCH_OPTION_ALLOW_INACTIVE]; ok { -- cgit v1.2.3-1-g7c22