diff --git a/app/notification.go b/app/notification.go index 2bbb206e41..f57dcd3c45 100644 --- a/app/notification.go +++ b/app/notification.go @@ -287,6 +287,32 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod updateMentionChans = append(updateMentionChans, umc) } + // Make sure all mention updates are complete to prevent race conditions. + // Probably better to batch these DB updates in the future + // MUST be completed before push notifications send + for _, umc := range updateMentionChans { + if err := <-umc; err != nil { + mlog.Warn( + "Failed to update mention count", + mlog.String("post_id", post.Id), + mlog.String("channel_id", post.ChannelId), + mlog.Err(err), + ) + } + } + + // Log the problems that might have occurred while auto following the thread + for _, mac := range mentionAutofollowChans { + if err := <-mac; err != nil { + mlog.Warn( + "Failed to update thread autofollow from mention", + mlog.String("post_id", post.Id), + mlog.String("channel_id", post.ChannelId), + mlog.Err(err), + ) + } + } + notificationsForCRT := &CRTNotifiers{} if isCRTAllowed && post.RootId != "" { for _, uid := range followers { @@ -376,31 +402,6 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod } } - // Make sure all mention updates are complete to prevent race - // Probably better to batch these DB updates in the future - // MUST be completed before push notifications send - for _, umc := range updateMentionChans { - if err := <-umc; err != nil { - mlog.Warn( - "Failed to update mention count", - mlog.String("post_id", post.Id), - mlog.String("channel_id", post.ChannelId), - mlog.Err(err), - ) - } - } - - // Log the problems that might have occurred while auto following the thread - for _, mac := range mentionAutofollowChans { - if err := <-mac; err != nil { - mlog.Warn( - "Failed to update thread autofollow from mention", - mlog.String("post_id", post.Id), - mlog.String("channel_id", post.ChannelId), - mlog.Err(err), - ) - } - } sendPushNotifications := false if *a.Config().EmailSettings.SendPushNotifications { pushServer := *a.Config().EmailSettings.PushNotificationServer