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
Этот коммит содержится в:
Joram Wilander
2016-12-02 12:24:22 -05:00
коммит произвёл Christopher Speller
родитель c952985ffd
Коммит ea26c72dad
3 изменённых файлов: 186 добавлений и 10 удалений

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

@@ -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 {