github.com/rajatvaryani/mattermost-server@v5.11.1+incompatible/model/user_search.go (about) 1 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "encoding/json" 8 "io" 9 ) 10 11 const USER_SEARCH_MAX_LIMIT = 1000 12 const USER_SEARCH_DEFAULT_LIMIT = 100 13 14 // UserSearch captures the parameters provided by a client for initiating a user search. 15 type UserSearch struct { 16 Term string `json:"term"` 17 TeamId string `json:"team_id"` 18 NotInTeamId string `json:"not_in_team_id"` 19 InChannelId string `json:"in_channel_id"` 20 NotInChannelId string `json:"not_in_channel_id"` 21 AllowInactive bool `json:"allow_inactive"` 22 WithoutTeam bool `json:"without_team"` 23 Limit int `json:"limit"` 24 Role string `json:"role"` 25 } 26 27 // ToJson convert a User to a json string 28 func (u *UserSearch) ToJson() []byte { 29 b, _ := json.Marshal(u) 30 return b 31 } 32 33 // UserSearchFromJson will decode the input and return a User 34 func UserSearchFromJson(data io.Reader) *UserSearch { 35 var us *UserSearch 36 json.NewDecoder(data).Decode(&us) 37 38 if us.Limit == 0 { 39 us.Limit = USER_SEARCH_DEFAULT_LIMIT 40 } 41 42 return us 43 } 44 45 // UserSearchOptions captures internal parameters derived from the user's permissions and a 46 // UserSearch request. 47 type UserSearchOptions struct { 48 // IsAdmin tracks whether or not the search is being conducted by an administrator. 49 IsAdmin bool 50 // AllowEmails allows search to examine the emails of users. 51 AllowEmails bool 52 // AllowFullNames allows search to examine the full names of users, vs. just usernames and nicknames. 53 AllowFullNames bool 54 // AllowInactive configures whether or not to return inactive users in the search results. 55 AllowInactive bool 56 // Limit limits the total number of results returned. 57 Limit int 58 // Filters for the given role 59 Role string 60 }