mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 09:49:24 +02:00
New model updates for series, collections, authors routes
This commit is contained in:
parent
73257188f6
commit
2d19208340
19 changed files with 432 additions and 247 deletions
|
@ -3,6 +3,10 @@ const Logger = require('../Logger')
|
|||
class SeriesController {
|
||||
constructor() { }
|
||||
|
||||
async findOne(req, res) {
|
||||
return res.json(req.series)
|
||||
}
|
||||
|
||||
async search(req, res) {
|
||||
var q = (req.query.q || '').toLowerCase()
|
||||
if (!q) return res.json([])
|
||||
|
@ -11,5 +15,21 @@ class SeriesController {
|
|||
series = series.slice(0, limit)
|
||||
res.json(series)
|
||||
}
|
||||
|
||||
middleware(req, res, next) {
|
||||
var series = this.db.series.find(se => se.id === req.params.id)
|
||||
if (!series) return res.sendStatus(404)
|
||||
|
||||
if (req.method == 'DELETE' && !req.user.canDelete) {
|
||||
Logger.warn(`[SeriesController] User attempted to delete without permission`, req.user)
|
||||
return res.sendStatus(403)
|
||||
} else if ((req.method == 'PATCH' || req.method == 'POST') && !req.user.canUpdate) {
|
||||
Logger.warn('[SeriesController] User attempted to update without permission', req.user)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
|
||||
req.series = series
|
||||
next()
|
||||
}
|
||||
}
|
||||
module.exports = new SeriesController()
|
Loading…
Add table
Add a link
Reference in a new issue