diff options
Diffstat (limited to 'connector/mattermost')
-rw-r--r-- | connector/mattermost/mattermost.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/connector/mattermost/mattermost.go b/connector/mattermost/mattermost.go index 4490f2a..ea8377c 100644 --- a/connector/mattermost/mattermost.go +++ b/connector/mattermost/mattermost.go @@ -254,8 +254,19 @@ func (mm *Mattermost) Leave(roomId RoomID) { } func (mm *Mattermost) SearchForUsers(query string) ([]UserSearchResult, error) { - // TODO - return nil, fmt.Errorf("Not implemented") + query = strings.ToLower(query) + 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) { |