MM-35123 - CRT: Replying to a post with mention causes two mention badges to appear (#17506)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
29341b8fe5
Коммит
861745e33b
@@ -172,11 +172,12 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
|||||||
mentionAutofollowChans := []chan *model.AppError{}
|
mentionAutofollowChans := []chan *model.AppError{}
|
||||||
threadParticipants := map[string]bool{post.UserId: true}
|
threadParticipants := map[string]bool{post.UserId: true}
|
||||||
if *a.Config().ServiceSettings.ThreadAutoFollow && post.RootId != "" {
|
if *a.Config().ServiceSettings.ThreadAutoFollow && post.RootId != "" {
|
||||||
|
var rootMentions *ExplicitMentions
|
||||||
if parentPostList != nil {
|
if parentPostList != nil {
|
||||||
threadParticipants[parentPostList.Posts[parentPostList.Order[0]].UserId] = true
|
threadParticipants[parentPostList.Posts[parentPostList.Order[0]].UserId] = true
|
||||||
if channel.Type != model.CHANNEL_DIRECT {
|
if channel.Type != model.CHANNEL_DIRECT {
|
||||||
rootPost := parentPostList.Posts[parentPostList.Order[0]]
|
rootPost := parentPostList.Posts[parentPostList.Order[0]]
|
||||||
rootMentions := getExplicitMentions(rootPost, keywords, groups)
|
rootMentions = getExplicitMentions(rootPost, keywords, groups)
|
||||||
for id := range rootMentions.Mentions {
|
for id := range rootMentions.Mentions {
|
||||||
threadParticipants[id] = true
|
threadParticipants[id] = true
|
||||||
}
|
}
|
||||||
@@ -190,6 +191,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
|||||||
mac := make(chan *model.AppError, 1)
|
mac := make(chan *model.AppError, 1)
|
||||||
go func(userID string) {
|
go func(userID string) {
|
||||||
defer close(mac)
|
defer close(mac)
|
||||||
|
isRootMention := false
|
||||||
|
if rootMentions != nil {
|
||||||
|
_, isRootMention = rootMentions.Mentions[userID]
|
||||||
|
}
|
||||||
_, incrementMentions := mentions.Mentions[userID]
|
_, incrementMentions := mentions.Mentions[userID]
|
||||||
// if the user was not explicitly mentioned, check if they explicitly unfollowed the thread
|
// if the user was not explicitly mentioned, check if they explicitly unfollowed the thread
|
||||||
if !incrementMentions {
|
if !incrementMentions {
|
||||||
@@ -205,7 +210,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err := a.Srv().Store.Thread().MaintainMembership(userID, post.RootId, true, incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow, userID == post.UserId, userID == post.UserId)
|
_, err := a.Srv().Store.Thread().MaintainMembership(userID, post.RootId, true, !isRootMention && incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow, userID == post.UserId, userID == post.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, err.Error(), http.StatusInternalServerError)
|
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user