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
@@ -12,7 +12,8 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
)
|
||||
|
||||
// fixMention replaces any mentions in a post for the user with the user's real username.
|
||||
// fixMention transforms @username:remotename mentions to @username format
|
||||
// Used when syncing posts to a user's home cluster
|
||||
func fixMention(post *model.Post, mentionMap model.UserMentionMap, user *model.User) {
|
||||
if post == nil || len(mentionMap) == 0 {
|
||||
return
|
||||
@@ -23,8 +24,8 @@ func fixMention(post *model.Post, mentionMap model.UserMentionMap, user *model.U
|
||||
return
|
||||
}
|
||||
|
||||
// there may be more than one mention for each user so we have to walk the whole map.
|
||||
for mention, id := range mentionMap {
|
||||
// Only process mentions with colons that match this user's ID
|
||||
if id == user.Id && strings.Contains(mention, ":") {
|
||||
post.Message = strings.ReplaceAll(post.Message, "@"+mention, "@"+realUsername)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user