diff options
author | =Corey Hulen <corey@hulen.com> | 2015-12-04 14:47:32 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-12-04 14:47:32 -0800 |
commit | 9435bd254b80bd0f75d8045b96b349a3be1d9308 (patch) | |
tree | 28a7ba6c0b2dd10502c75ca76edf758465a372b9 /api/post.go | |
parent | 1bee1e06e4d0110db274c076860fa97f76471ddb (diff) | |
download | chat-9435bd254b80bd0f75d8045b96b349a3be1d9308.tar.gz chat-9435bd254b80bd0f75d8045b96b349a3be1d9308.tar.bz2 chat-9435bd254b80bd0f75d8045b96b349a3be1d9308.zip |
PLT-1369 send core message
Diffstat (limited to 'api/post.go')
-rw-r--r-- | api/post.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/api/post.go b/api/post.go index 40c5efe8c..183a6444b 100644 --- a/api/post.go +++ b/api/post.go @@ -561,11 +561,34 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team, 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 + if len(post.Message) == 0 { + + otherFile := true + + if len(post.Filenames) != 0 { + for _, filename := range post.Filenames { + ext := filepath.Ext(filename) + if model.IsFileExtImage(ext) { + otherFile = false + break + } + } + } + + if otherFile { + msg.Message = profileMap[id].FirstName + " uploaded a file in " + channel.DisplayName + } else { + msg.Message = profileMap[id].FirstName + " uploaded an image in " + channel.DisplayName + } + + } else { + msg.Message = profileMap[id].FirstName + " wrote in " + channel.DisplayName + } + httpClient := http.Client{} request, _ := http.NewRequest("POST", *utils.Cfg.EmailSettings.PushNotificationServer+"/api/v1/send_push", strings.NewReader(msg.ToJson())) |