MM-14417: Messaging for mentions of users who are not in associated channel groups. (#10594)

* MM-14417: Adds support for out-of-channel notifications of users who are not in associated groups of group-constrained channels.

* MM-14417: Fix for mobile backwards compatibility.
Этот коммит содержится в:
Martin Kraft
2019-04-17 10:44:45 -04:00
коммит произвёл GitHub
родитель 762c257277
Коммит 84a59ddb39
5 изменённых файлов: 138 добавлений и 36 удалений

Просмотреть файл

@@ -9,6 +9,7 @@ import (
"io"
"net/http"
"regexp"
"sort"
"strings"
"unicode/utf8"
@@ -117,6 +118,53 @@ type UserForIndexing struct {
ChannelsIds []string `json:"channel_id"`
}
type UserSlice []*User
func (u UserSlice) Usernames() []string {
usernames := []string{}
for _, user := range u {
usernames = append(usernames, user.Username)
}
sort.Strings(usernames)
return usernames
}
func (u UserSlice) IDs() []string {
ids := []string{}
for _, user := range u {
ids = append(ids, user.Id)
}
return ids
}
func (u UserSlice) FilterByID(ids []string) UserSlice {
var matches []*User
for _, user := range u {
for _, id := range ids {
if id == user.Id {
matches = append(matches, user)
}
}
}
return UserSlice(matches)
}
func (u UserSlice) FilterWithoutID(ids []string) UserSlice {
var keep []*User
for _, user := range u {
present := false
for _, id := range ids {
if id == user.Id {
present = true
}
}
if !present {
keep = append(keep, user)
}
}
return UserSlice(keep)
}
func (u *User) DeepCopy() *User {
copyUser := *u
if u.AuthData != nil {