MM-62745: [Shared Channels] Fix duplicate mentioning - local user with the same username as someone on the remote server (#30734)
* initial checkin * i18n/en.json * fix e2e test * fix Makefile * initial checkin * fix logic * fix spacing * simplify * further simplify * address spec update * remove removeMention * simplify code * simplify code(2) * simplify code(3) * simplify code(4) * update comment * simplify comments * remove useless test --------- Co-authored-by: Catalin Tomai <catalintomai@catalins-macbook-pro-2.home>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e6ed3436fb
Коммит
62bd9d917d
@@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -398,7 +399,19 @@ func (scs *Service) fetchPostUsersForSync(sd *syncData) error {
|
||||
|
||||
// get mentions and users for each mention
|
||||
mentionMap := scs.app.MentionsToTeamMembers(request.EmptyContext(scs.server.Log()), post.Message, sc.TeamId)
|
||||
for _, userID := range mentionMap {
|
||||
|
||||
// Skip notifications for remote users unless mentioned with @username:remote format
|
||||
for mention, userID := range mentionMap {
|
||||
user, err := scs.server.GetStore().User().Get(context.Background(), userID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Skip remote users unless mention contains a colon (@username:remote)
|
||||
if user.RemoteId != nil && !strings.Contains(mention, ":") {
|
||||
continue
|
||||
}
|
||||
|
||||
userIDs[userID] = p2mm{
|
||||
post: post,
|
||||
mentionMap: mentionMap,
|
||||
@@ -429,8 +442,7 @@ func (scs *Service) fetchPostUsersForSync(sd *syncData) error {
|
||||
sd.profileImages[user.Id] = user
|
||||
}
|
||||
|
||||
// if this was a mention then put the real username in place of the username+remotename, but only
|
||||
// when sending to the remote that the user belongs to.
|
||||
// Transform @username:remote to @username when sending to a user's home cluster
|
||||
if v.post != nil && user.RemoteId != nil && *user.RemoteId == sd.rc.RemoteId {
|
||||
fixMention(v.post, v.mentionMap, user)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user