summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-01-16 16:17:44 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2017-01-16 16:17:44 -0500
commit976296cd52533ff565407e55e872339cc312a0cf (patch)
tree0bbb59f67b5f708409db97ae531f2ea46cc1b2c1
parentaafb8be87c79c60df7534b3b69f967c6301b157e (diff)
downloadchat-976296cd52533ff565407e55e872339cc312a0cf.tar.gz
chat-976296cd52533ff565407e55e872339cc312a0cf.tar.bz2
chat-976296cd52533ff565407e55e872339cc312a0cf.zip
Fixing performance issue with notifications (#5083)
-rw-r--r--api/post.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/api/post.go b/api/post.go
index 27a610199..bdbd32d2e 100644
--- a/api/post.go
+++ b/api/post.go
@@ -996,9 +996,11 @@ func sendNotificationEmail(c *Context, post *model.Post, user *model.User, chann
"Hour": fmt.Sprintf("%02d", tm.Hour()), "Minute": fmt.Sprintf("%02d", tm.Minute()),
"TimeZone": zone, "Month": month, "Day": day}))
- if err := utils.SendMail(user.Email, html.UnescapeString(subject), bodyPage.Render()); err != nil {
- l4g.Error(utils.T("api.post.send_notifications_and_forget.send.error"), user.Email, err)
- }
+ go func() {
+ if err := utils.SendMail(user.Email, html.UnescapeString(subject), bodyPage.Render()); err != nil {
+ l4g.Error(utils.T("api.post.send_notifications_and_forget.send.error"), user.Email, err)
+ }
+ }()
if einterfaces.GetMetricsInterface() != nil {
einterfaces.GetMetricsInterface().IncrementPostSentEmail()
@@ -1092,7 +1094,7 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
for _, session := range sessions {
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
- sendToPushProxy(tmpMessage)
+ go sendToPushProxy(tmpMessage)
if einterfaces.GetMetricsInterface() != nil {
einterfaces.GetMetricsInterface().IncrementPostSentPush()
}
@@ -1120,7 +1122,7 @@ func clearPushNotification(userId string, channelId string) {
for _, session := range sessions {
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
- sendToPushProxy(tmpMessage)
+ go sendToPushProxy(tmpMessage)
}
}