summaryrefslogtreecommitdiffstats
path: root/store/sql_session_store.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-10-24 17:04:11 -0700
committerenahum <nahumhbl@gmail.com>2016-10-24 21:04:11 -0300
commit9071553165cfc9f073f57aab96a3e6a7c771c8f3 (patch)
tree0dabe6e35b0121997051e54d0823a4499d0cae70 /store/sql_session_store.go
parent4d9f5173bc81fcaad8040b46b0d9950458412747 (diff)
downloadchat-9071553165cfc9f073f57aab96a3e6a7c771c8f3.tar.gz
chat-9071553165cfc9f073f57aab96a3e6a7c771c8f3.tar.bz2
chat-9071553165cfc9f073f57aab96a3e6a7c771c8f3.zip
PLT-4359 fixing push notification for more than 1 device (#4318)
* PLT-4359 fixing push notification for more than 1 device * Addressing feedback
Diffstat (limited to 'store/sql_session_store.go')
-rw-r--r--store/sql_session_store.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/store/sql_session_store.go b/store/sql_session_store.go
index 4e1bea3cf..5892dab01 100644
--- a/store/sql_session_store.go
+++ b/store/sql_session_store.go
@@ -168,6 +168,28 @@ func (me SqlSessionStore) GetSessions(userId string) StoreChannel {
return storeChannel
}
+func (me SqlSessionStore) GetSessionsWithActiveDeviceIds(userId string) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+
+ result := StoreResult{}
+ var sessions []*model.Session
+
+ if _, err := me.GetReplica().Select(&sessions, "SELECT * FROM Sessions WHERE UserId = :UserId AND ExpiresAt != 0 AND :ExpiresAt <= ExpiresAt AND DeviceId != ''", map[string]interface{}{"UserId": userId, "ExpiresAt": model.GetMillis()}); err != nil {
+ result.Err = model.NewLocAppError("SqlSessionStore.GetActiveSessionsWithDeviceIds", "store.sql_session.get_sessions.app_error", nil, err.Error())
+ } else {
+
+ result.Data = sessions
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (me SqlSessionStore) Remove(sessionIdOrToken string) StoreChannel {
storeChannel := make(StoreChannel, 1)