diff options
author | Corey Hulen <corey@hulen.com> | 2017-02-23 08:53:43 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-02-23 08:53:43 -0500 |
commit | ca7d3b6e7bc2e52cf40180a462492313f298e760 (patch) | |
tree | 4401b86f65d5a31bdaf3162a43969509b1f30229 /model | |
parent | 3b0f7163ab7e58a04c1fcadf7f615448bd4395a0 (diff) | |
download | chat-ca7d3b6e7bc2e52cf40180a462492313f298e760.tar.gz chat-ca7d3b6e7bc2e52cf40180a462492313f298e760.tar.bz2 chat-ca7d3b6e7bc2e52cf40180a462492313f298e760.zip |
Adding device Id for version 2 of native apps (#5505)
* Adding device Id for version 2
* Changing ids
Diffstat (limited to 'model')
-rw-r--r-- | model/push_notification.go | 17 | ||||
-rw-r--r-- | model/session.go | 3 |
2 files changed, 10 insertions, 10 deletions
diff --git a/model/push_notification.go b/model/push_notification.go index 3c010fb75..c426e01e5 100644 --- a/model/push_notification.go +++ b/model/push_notification.go @@ -10,8 +10,10 @@ import ( ) const ( - PUSH_NOTIFY_APPLE = "apple" - PUSH_NOTIFY_ANDROID = "android" + PUSH_NOTIFY_APPLE = "apple" + PUSH_NOTIFY_ANDROID = "android" + PUSH_NOTIFY_APPLE_REACT_NATIVE = "apple_rn" + PUSH_NOTIFY_ANDROID_REACT_NATIVE = "android_rn" PUSH_TYPE_MESSAGE = "message" PUSH_TYPE_CLEAR = "clear" @@ -46,12 +48,11 @@ 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+":") + + parts := strings.Split(deviceId, ":") + if len(parts) == 2 { + me.Platform = parts[0] + me.DeviceId = parts[1] } } diff --git a/model/session.go b/model/session.go index d8f9d5fab..277e910f6 100644 --- a/model/session.go +++ b/model/session.go @@ -111,8 +111,7 @@ func (me *Session) GetTeamByTeamId(teamId string) *TeamMember { } func (me *Session) IsMobileApp() bool { - return len(me.DeviceId) > 0 && - (strings.HasPrefix(me.DeviceId, PUSH_NOTIFY_APPLE+":") || strings.HasPrefix(me.DeviceId, PUSH_NOTIFY_ANDROID+":")) + return len(me.DeviceId) > 0 } func (me *Session) GetUserRoles() []string { |