summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-11-30 22:38:38 -0800
committer=Corey Hulen <corey@hulen.com>2015-11-30 22:38:38 -0800
commit68765a8f21db8a1b732f26f5bc1bf0e1a8e52d8f (patch)
treebc3d4e1f75398a84cc3be049b23cd29466e780a4 /api
parentb717a8100c3f2049fb94040ad8db11f56c0d9f13 (diff)
downloadchat-68765a8f21db8a1b732f26f5bc1bf0e1a8e52d8f.tar.gz
chat-68765a8f21db8a1b732f26f5bc1bf0e1a8e52d8f.tar.bz2
chat-68765a8f21db8a1b732f26f5bc1bf0e1a8e52d8f.zip
PLT-902 switching to push proxy server
Diffstat (limited to 'api')
-rw-r--r--api/post.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/api/post.go b/api/post.go
index 88d0127d3..81cc9a1c6 100644
--- a/api/post.go
+++ b/api/post.go
@@ -536,7 +536,7 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
l4g.Error("Failed to send mention email successfully email=%v err=%v", profileMap[id].Email, err)
}
- if len(utils.Cfg.EmailSettings.ApplePushServer) > 0 {
+ if *utils.Cfg.EmailSettings.SendPushNotifications {
sessionChan := Srv.Store.Session().GetSessions(id)
if result := <-sessionChan; result.Err != nil {
l4g.Error("Failed to retrieve sessions in notifications id=%v, err=%v", id, result.Err)
@@ -548,7 +548,19 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
if len(session.DeviceId) > 0 && alreadySeen[session.DeviceId] == "" && strings.HasPrefix(session.DeviceId, "apple:") {
alreadySeen[session.DeviceId] = session.DeviceId
- utils.SendAppleNotifyAndForget(strings.TrimPrefix(session.DeviceId, "apple:"), subjectPage.Render(), 1)
+ msg := model.PushNotification{}
+ msg.Platform = model.PUSH_NOTIFY_APPLE
+ msg.Message = subjectPage.Render()
+ msg.Badge = 1
+ msg.DeviceId = strings.TrimPrefix(session.DeviceId, "apple:")
+ msg.ServerId = utils.CfgDiagnosticId
+
+ httpClient := http.Client{}
+ request, _ := http.NewRequest("POST", *utils.Cfg.EmailSettings.PushNotificationServer+"/api/v1/send_push", strings.NewReader(msg.ToJson()))
+
+ if _, err := httpClient.Do(request); err != nil {
+ l4g.Error("Failed to send push notificationid=%v, err=%v", id, err)
+ }
}
}
}