diff --git a/server/controllers/MeController.js b/server/controllers/MeController.js index 00a04a04..66e44726 100644 --- a/server/controllers/MeController.js +++ b/server/controllers/MeController.js @@ -16,6 +16,15 @@ class MeController { res.json(listeningStats) } + // GET: api/me/progress/:id/:episodeId? + async getMediaProgress(req, res) { + const mediaProgress = req.user.getMediaProgress(req.id, req.episodeId || null) + if (!mediaProgress) { + return res.sendStatus(404) + } + res.json(mediaProgress) + } + // DELETE: api/me/progress/:id async removeMediaProgress(req, res) { var wasRemoved = req.user.removeMediaProgress(req.params.id) diff --git a/server/controllers/SessionController.js b/server/controllers/SessionController.js index b54c475e..9b6d5a5c 100644 --- a/server/controllers/SessionController.js +++ b/server/controllers/SessionController.js @@ -7,6 +7,12 @@ class SessionController { return res.json(req.session) } + getSession(req, res) { + var libraryItem = this.db.getLibraryItem(req.session.libraryItemId) + var sessionForClient = req.session.toJSONForClient(libraryItem) + res.json(sessionForClient) + } + // POST: api/session/:id/sync sync(req, res) { this.playbackSessionManager.syncSessionRequest(req.user, req.session, req.body, res) diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js index 769ee268..aec6f3f0 100644 --- a/server/routers/ApiRouter.js +++ b/server/routers/ApiRouter.js @@ -131,6 +131,7 @@ class ApiRouter { // this.router.get('/me/listening-sessions', MeController.getListeningSessions.bind(this)) this.router.get('/me/listening-stats', MeController.getListeningStats.bind(this)) + this.router.get('/me/progress/:id/:episodeId?', MeController.getMediaProgress.bind(this)) this.router.patch('/me/progress/batch/update', MeController.batchUpdateMediaProgress.bind(this)) this.router.patch('/me/progress/:id', MeController.createUpdateMediaProgress.bind(this)) this.router.delete('/me/progress/:id', MeController.removeMediaProgress.bind(this)) @@ -173,6 +174,7 @@ class ApiRouter { // // Playback Session Routes // + this.router.get('/session/:id', SessionController.middleware.bind(this), SessionController.getSession.bind(this)) this.router.post('/session/:id/sync', SessionController.middleware.bind(this), SessionController.sync.bind(this)) this.router.post('/session/:id/close', SessionController.middleware.bind(this), SessionController.close.bind(this)) this.router.post('/session/local', SessionController.syncLocal.bind(this))