mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-28 03:30:37 +02:00
Switch to using the websocket for confirmation of batch updates, allowing the main request to be done asynchronously
This commit is contained in:
parent
2d6f9bab8b
commit
3e7a76574b
3 changed files with 26 additions and 14 deletions
|
@ -307,6 +307,11 @@ class LibraryItemController {
|
|||
|
||||
// POST: api/items/batch/quickmatch
|
||||
async batchQuickMatch(req, res) {
|
||||
if (!req.user.isAdminOrUp) {
|
||||
Logger.warn('User other than admin attempted to batch quick match library items', req.user)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
|
||||
var itemsUpdated = 0
|
||||
var itemsUnmatched = 0
|
||||
|
||||
|
@ -316,6 +321,7 @@ class LibraryItemController {
|
|||
if (!items || !items.length) {
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
res.sendStatus(200);
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i])
|
||||
|
@ -327,11 +333,12 @@ class LibraryItemController {
|
|||
}
|
||||
}
|
||||
|
||||
res.json({
|
||||
var result = {
|
||||
success: itemsUpdated > 0,
|
||||
updates: itemsUpdated,
|
||||
unmatched: itemsUnmatched
|
||||
})
|
||||
unmatched: itemsUnmatched
|
||||
};
|
||||
this.clientEmitter(req.user.id, 'batch_quickmatch_complete', result)
|
||||
}
|
||||
|
||||
// DELETE: api/items/all
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue