diff options
author | Corey Hulen <corey@hulen.com> | 2017-08-28 07:08:37 -0700 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-08-28 10:08:37 -0400 |
commit | 1709b94227ed33e789f1be00d26ebbb972ce86b7 (patch) | |
tree | bfadf6b52b2ce8985b59529aeb1b890fa214190d /app/notification.go | |
parent | a12cf549cf0dc394189f7a37f090bd3eebbca8ca (diff) | |
download | chat-1709b94227ed33e789f1be00d26ebbb972ce86b7.tar.gz chat-1709b94227ed33e789f1be00d26ebbb972ce86b7.tar.bz2 chat-1709b94227ed33e789f1be00d26ebbb972ce86b7.zip |
PLT-5745 Cleaning up duplicate calls (#7298)
* PLT-5745 Cleaning up duplicate calls
* Fixing missing calls
* Fixing broken test
Diffstat (limited to 'app/notification.go')
-rw-r--r-- | app/notification.go | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/app/notification.go b/app/notification.go index 21271c716..1d3416794 100644 --- a/app/notification.go +++ b/app/notification.go @@ -25,7 +25,7 @@ import ( "github.com/nicksnyder/go-i18n/i18n" ) -func SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User) ([]string, *model.AppError) { +func SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList) ([]string, *model.AppError) { pchan := Srv.Store.User().GetAllProfilesInChannel(channel.Id, true) cmnchan := Srv.Store.Channel().GetAllChannelMembersNotifyPropsForChannel(channel.Id, true) var fchan store.StoreChannel @@ -77,17 +77,11 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe mentionedUserIds, potentialOtherMentions, hereNotification, channelNotification, allNotification = GetExplicitMentions(post.Message, keywords) // get users that have comment thread mentions enabled - if len(post.RootId) > 0 { - if result := <-Srv.Store.Post().Get(post.RootId); result.Err != nil { - return nil, result.Err - } else { - list := result.Data.(*model.PostList) - - for _, threadPost := range list.Posts { - profile := profileMap[threadPost.UserId] - if profile != nil && (profile.NotifyProps["comments"] == "any" || (profile.NotifyProps["comments"] == "root" && threadPost.Id == list.Order[0])) { - mentionedUserIds[threadPost.UserId] = true - } + if len(post.RootId) > 0 && parentPostList != nil { + for _, threadPost := range parentPostList.Posts { + profile := profileMap[threadPost.UserId] + if profile != nil && (profile.NotifyProps["comments"] == "any" || (profile.NotifyProps["comments"] == "root" && threadPost.Id == parentPostList.Order[0])) { + mentionedUserIds[threadPost.UserId] = true } } } |