mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-09 07:14:52 +02:00
Clean up ApiRouter adding MiscController, move upload and scan to api endpoints
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
const Logger = require('../Logger')
|
||||
const { reqSupportsWebp } = require('../utils/index')
|
||||
const { ScanResult } = require('../utils/constants')
|
||||
|
||||
class LibraryItemController {
|
||||
constructor() { }
|
||||
@ -239,6 +240,18 @@ class LibraryItemController {
|
||||
else res.sendStatus(500)
|
||||
}
|
||||
|
||||
// GET: api/items/:id/scan (Root)
|
||||
async scan(req, res) {
|
||||
if (!req.user.isRoot) {
|
||||
Logger.error(`[LibraryItemController] Non-root user attempted to scan library item`, req.user)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
var result = await this.scanner.scanLibraryItemById(req.libraryItem.id)
|
||||
res.json({
|
||||
result: Object.keys(ScanResult).find(key => ScanResult[key] == result)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
middleware(req, res, next) {
|
||||
var item = this.db.libraryItems.find(li => li.id === req.params.id)
|
||||
|
Reference in New Issue
Block a user