summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorElias Nahum <nahumhbl@gmail.com>2016-03-11 00:14:55 -0300
committerElias Nahum <nahumhbl@gmail.com>2016-03-17 13:20:17 -0300
commit1f5c8c4e4ebb2e163278f3e62d640f41a2df7294 (patch)
treea659674c9980e23752fc8d9f07eb48014c8bce26 /api
parentd383ed2f8dfc320c090b67d9f2e2d111710ca3cf (diff)
downloadchat-1f5c8c4e4ebb2e163278f3e62d640f41a2df7294.tar.gz
chat-1f5c8c4e4ebb2e163278f3e62d640f41a2df7294.tar.bz2
chat-1f5c8c4e4ebb2e163278f3e62d640f41a2df7294.zip
Option to enable full snippets in push notifications
Diffstat (limited to 'api')
-rw-r--r--api/post.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/api/post.go b/api/post.go
index d0ec5826a..36fd4ee79 100644
--- a/api/post.go
+++ b/api/post.go
@@ -670,8 +670,15 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
alreadySeen[session.DeviceId] = session.DeviceId
msg := model.PushNotification{}
- msg.Badge = 1
+ if badge := <-Srv.Store.User().GetUnreadCount(id); badge.Err != nil {
+ msg.Badge = 1
+ l4g.Error(utils.T("store.sql_user.get_unread_count.app_error"), id, badge.Err)
+ } else {
+ msg.Badge = int(badge.Data.(int64))
+ }
msg.ServerId = utils.CfgDiagnosticId
+ msg.ChannelId = channel.Id
+ msg.ChannelName = channel.Name
if strings.HasPrefix(session.DeviceId, model.PUSH_NOTIFY_APPLE+":") {
msg.Platform = model.PUSH_NOTIFY_APPLE
@@ -681,10 +688,20 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
msg.DeviceId = strings.TrimPrefix(session.DeviceId, model.PUSH_NOTIFY_ANDROID+":")
}
- if channel.Type == model.CHANNEL_DIRECT {
- msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_message")
+ if *utils.Cfg.EmailSettings.PushNotificationContents == model.FULL_NOTIFICATION {
+ if channel.Type == model.CHANNEL_DIRECT {
+ msg.Category = model.CATEGORY_DM
+ msg.Message = "@" + senderName + ": " + model.ClearMentionTags(post.Message)
+ } else {
+ msg.Message = "@" + senderName + " @ " + channelName + ": " + model.ClearMentionTags(post.Message)
+ }
} else {
- msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention") + channelName
+ if channel.Type == model.CHANNEL_DIRECT {
+ msg.Category = model.CATEGORY_DM
+ msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_message")
+ } else {
+ msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention") + channelName
+ }
}
tr := &http.Transport{