Mattermost user search
This commit is contained in:
parent
586706f02b
commit
15e3dc46cf
1 changed files with 13 additions and 2 deletions
|
@ -254,8 +254,19 @@ func (mm *Mattermost) Leave(roomId RoomID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mm *Mattermost) SearchForUsers(query string) ([]UserSearchResult, error) {
|
func (mm *Mattermost) SearchForUsers(query string) ([]UserSearchResult, error) {
|
||||||
// TODO
|
query = strings.ToLower(query)
|
||||||
return nil, fmt.Errorf("Not implemented")
|
ret := []UserSearchResult{}
|
||||||
|
for _, user := range mm.conn.Users {
|
||||||
|
if strings.Contains(strings.ToLower(user.Username), query) ||
|
||||||
|
strings.Contains(strings.ToLower(user.Nickname), query) ||
|
||||||
|
strings.Contains(strings.ToLower(user.GetDisplayName(model.SHOW_NICKNAME_FULLNAME)), query) {
|
||||||
|
ret = append(ret, UserSearchResult{
|
||||||
|
ID: UserID(fmt.Sprintf("%s@%s", user.Username, mm.server)),
|
||||||
|
DisplayName: user.GetDisplayName(model.SHOW_NICKNAME_FULLNAME),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mm *Mattermost) Send(event *Event) (string, error) {
|
func (mm *Mattermost) Send(event *Event) (string, error) {
|
||||||
|
|
Loading…
Reference in a new issue