diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-08-31 12:52:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-31 12:52:14 -0400 |
commit | 26f96b240ddc8cf8c56decea72102b10238e0a43 (patch) | |
tree | 7eda509038de3d6b95a02b95bee2ad72e2e3a063 /model/push_notification.go | |
parent | b0b39ce71cd77fbffbf23d56b20db1927f0c6cb1 (diff) | |
download | chat-26f96b240ddc8cf8c56decea72102b10238e0a43.tar.gz chat-26f96b240ddc8cf8c56decea72102b10238e0a43.tar.bz2 chat-26f96b240ddc8cf8c56decea72102b10238e0a43.zip |
PLT-3462 Add the ability to clear push notifications after channel is viewed (#3834)
* Add the ability to clear push notifications after channel is viewed
* Fix race condition between updating the mention count and reading it when sending push notifications
Diffstat (limited to 'model/push_notification.go')
-rw-r--r-- | model/push_notification.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/model/push_notification.go b/model/push_notification.go index 666dd8f7d..d4c380291 100644 --- a/model/push_notification.go +++ b/model/push_notification.go @@ -6,12 +6,16 @@ package model import ( "encoding/json" "io" + "strings" ) const ( PUSH_NOTIFY_APPLE = "apple" PUSH_NOTIFY_ANDROID = "android" + PUSH_TYPE_MESSAGE = "message" + PUSH_TYPE_CLEAR = "clear" + CATEGORY_DM = "DIRECT_MESSAGE" MHPNS = "https://push.mattermost.com" @@ -28,6 +32,7 @@ type PushNotification struct { ContentAvailable int `json:"cont_ava"` ChannelId string `json:"channel_id"` ChannelName string `json:"channel_name"` + Type string `json:"type"` } func (me *PushNotification) ToJson() string { @@ -39,6 +44,16 @@ func (me *PushNotification) ToJson() string { } } +func (me *PushNotification) SetDeviceIdAndPlatform(deviceId string) { + if strings.HasPrefix(deviceId, PUSH_NOTIFY_APPLE+":") { + me.Platform = PUSH_NOTIFY_APPLE + me.DeviceId = strings.TrimPrefix(deviceId, PUSH_NOTIFY_APPLE+":") + } else if strings.HasPrefix(deviceId, PUSH_NOTIFY_ANDROID+":") { + me.Platform = PUSH_NOTIFY_ANDROID + me.DeviceId = strings.TrimPrefix(deviceId, PUSH_NOTIFY_ANDROID+":") + } +} + func PushNotificationFromJson(data io.Reader) *PushNotification { decoder := json.NewDecoder(data) var me PushNotification |