diff options
Diffstat (limited to 'api/post.go')
-rw-r--r-- | api/post.go | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/api/post.go b/api/post.go index 4533823f6..951ccb527 100644 --- a/api/post.go +++ b/api/post.go @@ -535,9 +535,8 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel * return model.SplitRunes[c] } splitMessage := strings.Fields(post.Message) + var userIds []string for _, word := range splitMessage { - var userIds []string - // Non-case-sensitive check for regular keys if ids, match := keywordMap[strings.ToLower(word)]; match { userIds = append(userIds, ids...) @@ -565,14 +564,30 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel * } } } + } + + if len(post.RootId) > 0 { + if result := <-Srv.Store.Post().Get(post.RootId); result.Err != nil { + l4g.Error(utils.T("api.post.send_notifications_and_forget.comment_thread.error"), post.RootId, result.Err) + return + } else { + list := result.Data.(*model.PostList) - for _, userId := range userIds { - if post.UserId == userId && post.Props["from_webhook"] != "true" { - continue + for _, threadPost := range list.Posts { + profile := profileMap[threadPost.UserId] + if profile.NotifyProps["comments"] == "any" || (profile.NotifyProps["comments"] == "root" && threadPost.Id == list.Order[0]) { + userIds = append(userIds, threadPost.UserId) + } } + } + } - mentionedUserIds[userId] = true + for _, userId := range userIds { + if post.UserId == userId && post.Props["from_webhook"] != "true" { + continue } + + mentionedUserIds[userId] = true } for id := range mentionedUserIds { |