diff options
author | Alex Auvolat <alex@adnab.me> | 2020-03-09 18:12:25 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-03-09 18:12:25 +0100 |
commit | 15e3dc46cf485f6833e1d6a669a23abe43869ade (patch) | |
tree | 1c9821935e0fd46b9c49c5eaf5cc9edcafc97f3d | |
parent | 586706f02bfa7c41a5eec61c783c452350d8c6c1 (diff) | |
download | easybridge-15e3dc46cf485f6833e1d6a669a23abe43869ade.tar.gz easybridge-15e3dc46cf485f6833e1d6a669a23abe43869ade.zip |
Mattermost user search
-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) { |