PLT-914 Add mention notifications for replies on a comment thread (#3130)

* PLT-914 Add mention notifications for replies on a comment thread

* remove useless store method
fix highlighting comments posted before th user write something to thread

* refactor out isCommentMention function after rebase

* change comment bar highlighting to replay icon mention highlighting

* settings and always visible highlight

* fix unit tests for new settings

* change highlight behaviour
- if any message in comment thread generates mention - all thread is highlighted
- remove always visible highlightion

* fix bug about the textarea in the center channel not clearing

* fix default settings value notify_props.comments

* do not highlight own comments if there is no other user's messages in thread

* refactor out ReactDOM.findDOMNode

* refactor out using of UserStore from component
Этот коммит содержится в:
samogot
2016-07-19 15:27:23 +03:00
коммит произвёл Christopher Speller
родитель febe3a01cd
Коммит f31e8e09f5
11 изменённых файлов: 233 добавлений и 23 удалений

Просмотреть файл

@@ -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,16 +564,32 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
}
}
}
for _, userId := range userIds {
if post.UserId == userId && post.Props["from_webhook"] != "true" {
continue
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 _, 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 {
go updateMentionCount(post.ChannelId, id)
}