summaryrefslogtreecommitdiffstats
path: root/app/notification.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-03 10:53:53 -0500
committerGitHub <noreply@github.com>2017-10-03 10:53:53 -0500
commit5e69ce099f521aa49fc267c62235c003eae530ff (patch)
treec7177e4cac419082753225819f62d07c8b5671e8 /app/notification.go
parentbfe7955fb0c72bb6f3e0a1e0aaca70cff27d7ddc (diff)
downloadchat-5e69ce099f521aa49fc267c62235c003eae530ff.tar.gz
chat-5e69ce099f521aa49fc267c62235c003eae530ff.tar.bz2
chat-5e69ce099f521aa49fc267c62235c003eae530ff.zip
Goroutine wranglin (#7556)
* goroutine wranglin * synchronize WebConn.WritePump
Diffstat (limited to 'app/notification.go')
-rw-r--r--app/notification.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/notification.go b/app/notification.go
index 0859dfd20..3df4a789f 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -94,7 +94,9 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
if result := <-a.Srv.Store.User().GetProfilesByUsernames(potentialOtherMentions, team.Id); result.Err == nil {
outOfChannelMentions := result.Data.([]*model.User)
if channel.Type != model.CHANNEL_GROUP {
- go a.sendOutOfChannelMentions(sender, post, team.Id, outOfChannelMentions)
+ a.Go(func() {
+ a.sendOutOfChannelMentions(sender, post, team.Id, outOfChannelMentions)
+ })
}
}
}
@@ -362,11 +364,11 @@ func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel
teamURL := utils.GetSiteURL() + "/" + team.Name
var bodyText = a.getNotificationEmailBody(user, post, channel, senderName, team.Name, teamURL, emailNotificationContentsType, translateFunc)
- go func() {
+ a.Go(func() {
if err := utils.SendMail(user.Email, html.UnescapeString(subjectText), bodyText); err != nil {
l4g.Error(utils.T("api.post.send_notifications_and_forget.send.error"), user.Email, err)
}
- }()
+ })
if a.Metrics != nil {
a.Metrics.IncrementPostSentEmail()
@@ -638,7 +640,11 @@ func (a *App) sendPushNotification(post *model.Post, user *model.User, channel *
l4g.Debug("Sending push notification to device %v for user %v with msg of '%v'", tmpMessage.DeviceId, user.Id, msg.Message)
- go a.sendToPushProxy(tmpMessage, session)
+ a.Go(func(session *model.Session) func() {
+ return func() {
+ a.sendToPushProxy(tmpMessage, session)
+ }
+ }(session))
if a.Metrics != nil {
a.Metrics.IncrementPostSentPush()
@@ -649,7 +655,7 @@ func (a *App) sendPushNotification(post *model.Post, user *model.User, channel *
}
func (a *App) ClearPushNotification(userId string, channelId string) {
- go func() {
+ a.Go(func() {
// Sleep is to allow the read replicas a chance to fully sync
// the unread count for sending an accurate count.
// Delaying a little doesn't hurt anything and is cheaper than
@@ -678,9 +684,11 @@ func (a *App) ClearPushNotification(userId string, channelId string) {
for _, session := range sessions {
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
- go a.sendToPushProxy(tmpMessage, session)
+ a.Go(func() {
+ a.sendToPushProxy(tmpMessage, session)
+ })
}
- }()
+ })
}
func (a *App) sendToPushProxy(msg model.PushNotification, session *model.Session) {