summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-12-02 12:24:22 -0500
committerChristopher Speller <crspeller@gmail.com>2016-12-02 12:24:22 -0500
commitea26c72dad3bc1a2ccb020310b635bd6484a1b15 (patch)
treeec73bb8521deb49fbd08033ef0543c2f0311cdda /store
parentc952985ffd035f95e82fef2fbc2e8bd48ab9ec3b (diff)
downloadchat-ea26c72dad3bc1a2ccb020310b635bd6484a1b15.tar.gz
chat-ea26c72dad3bc1a2ccb020310b635bd6484a1b15.tar.bz2
chat-ea26c72dad3bc1a2ccb020310b635bd6484a1b15.zip
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
Diffstat (limited to 'store')
-rw-r--r--store/sql_user_store.go26
1 files changed, 18 insertions, 8 deletions
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 {