Mattermost user search

This commit is contained in:
Alex 2020-03-09 18:12:25 +01:00
parent 586706f02b
commit 15e3dc46cf

View file

@ -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) {