MM-35103 Replies in a thread with an initial mention triggers notification each time (#17503)
* only process parent post mentions for threads in order to autofollow * don't use merge since it modifies the original Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
978d886e3f
Коммит
d819eb224c
@@ -83,7 +83,8 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
|
||||
mentions := &ExplicitMentions{}
|
||||
allActivityPushUserIds := []string{}
|
||||
|
||||
var allowChannelMentions bool
|
||||
var keywords map[string][]string
|
||||
if channel.Type == model.CHANNEL_DIRECT {
|
||||
otherUserId := channel.GetOtherUserIdForDM(post.UserId)
|
||||
|
||||
@@ -96,8 +97,8 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
mentions.addMention(post.UserId, DMMention)
|
||||
}
|
||||
} else {
|
||||
allowChannelMentions := a.allowChannelMentions(post, len(profileMap))
|
||||
keywords := a.getMentionKeywordsInChannel(profileMap, allowChannelMentions, channelMemberNotifyPropsMap)
|
||||
allowChannelMentions = a.allowChannelMentions(post, len(profileMap))
|
||||
keywords = a.getMentionKeywordsInChannel(profileMap, allowChannelMentions, channelMemberNotifyPropsMap)
|
||||
|
||||
mentions = getExplicitMentions(post, keywords, groups)
|
||||
// Add an implicit mention when a user is added to a channel
|
||||
@@ -123,8 +124,6 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
|
||||
// get users that have comment thread mentions enabled
|
||||
if post.RootId != "" && parentPostList != nil {
|
||||
rootPost := parentPostList.Posts[parentPostList.Order[0]]
|
||||
mentions.merge(getExplicitMentions(rootPost, keywords, groups))
|
||||
for _, threadPost := range parentPostList.Posts {
|
||||
profile := profileMap[threadPost.UserId]
|
||||
if profile == nil {
|
||||
@@ -175,6 +174,13 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
|
||||
if *a.Config().ServiceSettings.ThreadAutoFollow && post.RootId != "" {
|
||||
if parentPostList != nil {
|
||||
threadParticipants[parentPostList.Posts[parentPostList.Order[0]].UserId] = true
|
||||
if channel.Type != model.CHANNEL_DIRECT {
|
||||
rootPost := parentPostList.Posts[parentPostList.Order[0]]
|
||||
rootMentions := getExplicitMentions(rootPost, keywords, groups)
|
||||
for id := range rootMentions.Mentions {
|
||||
threadParticipants[id] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
for id := range mentions.Mentions {
|
||||
threadParticipants[id] = true
|
||||
@@ -757,12 +763,6 @@ func (m *ExplicitMentions) addMentions(userIDs []string, mentionType MentionType
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ExplicitMentions) merge(other *ExplicitMentions) {
|
||||
for userID, mentionType := range other.Mentions {
|
||||
m.addMention(userID, mentionType)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ExplicitMentions) removeMention(userID string) {
|
||||
delete(m.Mentions, userID)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user