PLT-4359 fixing push notification for more than 1 device (#4318)

* PLT-4359 fixing push notification for more than 1 device

* Addressing feedback
Этот коммит содержится в:
Corey Hulen
2016-10-24 17:04:11 -07:00
коммит произвёл enahum
родитель 4d9f5173bc
Коммит 9071553165
4 изменённых файлов: 69 добавлений и 22 удалений

Просмотреть файл

@@ -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)