Add:API endpoint to get users online and open listening sessions #1125

This commit is contained in:
advplyr 2022-11-10 17:42:20 -06:00
parent abb4137d4c
commit fdf67e17a0
3 changed files with 19 additions and 5 deletions

View file

@ -183,6 +183,19 @@ class UserController {
res.json(this.userJsonWithItemProgressDetails(user, !req.user.isRoot))
}
// POST: api/users/online (admin)
async getOnlineUsers(req, res) {
if (!req.user.isAdminOrUp) {
return res.sendStatus(404)
}
const usersOnline = this.getUsersOnline()
res.json({
usersOnline,
openSessions: this.playbackSessionManager.sessions
})
}
middleware(req, res, next) {
if (!req.user.isAdminOrUp && req.user.id !== req.params.id) {
return res.sendStatus(403)