github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/model/user_autocomplete.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 type UserAutocompleteInChannel struct { 12 InChannel []*User `json:"in_channel"` 13 OutOfChannel []*User `json:"out_of_channel"` 14 } 15 16 type UserAutocompleteInTeam struct { 17 InTeam []*User `json:"in_team"` 18 } 19 20 type UserAutocomplete struct { 21 Users []*User `json:"users"` 22 OutOfChannel []*User `json:"out_of_channel,omitempty"` 23 } 24 25 func (o *UserAutocomplete) ToJson() string { 26 b, _ := json.Marshal(o) 27 return string(b) 28 } 29 30 func UserAutocompleteFromJson(data io.Reader) *UserAutocomplete { 31 decoder := json.NewDecoder(data) 32 autocomplete := new(UserAutocomplete) 33 err := decoder.Decode(&autocomplete) 34 if err == nil { 35 return autocomplete 36 } else { 37 return nil 38 } 39 } 40 41 func (o *UserAutocompleteInChannel) ToJson() string { 42 b, _ := json.Marshal(o) 43 return string(b) 44 } 45 46 func UserAutocompleteInChannelFromJson(data io.Reader) *UserAutocompleteInChannel { 47 var o *UserAutocompleteInChannel 48 json.NewDecoder(data).Decode(&o) 49 return o 50 } 51 52 func (o *UserAutocompleteInTeam) ToJson() string { 53 b, _ := json.Marshal(o) 54 return string(b) 55 } 56 57 func UserAutocompleteInTeamFromJson(data io.Reader) *UserAutocompleteInTeam { 58 var o *UserAutocompleteInTeam 59 json.NewDecoder(data).Decode(&o) 60 return o 61 }