mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-21 08:36:03 +02:00
Remove invalid RSS feeds on init and remove feeds when associated entity is removed
This commit is contained in:
parent
0e6b0d3eff
commit
c6763dee2d
5 changed files with 67 additions and 21 deletions
|
@ -40,8 +40,8 @@ class CollectionController {
|
|||
|
||||
async update(req, res) {
|
||||
const collection = req.collection
|
||||
var wasUpdated = collection.update(req.body)
|
||||
var jsonExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
const wasUpdated = collection.update(req.body)
|
||||
const jsonExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
if (wasUpdated) {
|
||||
await this.db.updateEntity('collection', collection)
|
||||
SocketAuthority.emitter('collection_updated', jsonExpanded)
|
||||
|
@ -51,7 +51,11 @@ class CollectionController {
|
|||
|
||||
async delete(req, res) {
|
||||
const collection = req.collection
|
||||
var jsonExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
const jsonExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
|
||||
// Close rss feed - remove from db and emit socket event
|
||||
await this.rssFeedManager.closeFeedForEntityId(collection.id)
|
||||
|
||||
await this.db.removeEntity('collection', collection.id)
|
||||
SocketAuthority.emitter('collection_removed', jsonExpanded)
|
||||
res.sendStatus(200)
|
||||
|
@ -59,7 +63,7 @@ class CollectionController {
|
|||
|
||||
async addBook(req, res) {
|
||||
const collection = req.collection
|
||||
var libraryItem = this.db.libraryItems.find(li => li.id === req.body.id)
|
||||
const libraryItem = this.db.libraryItems.find(li => li.id === req.body.id)
|
||||
if (!libraryItem) {
|
||||
return res.status(500).send('Book not found')
|
||||
}
|
||||
|
@ -70,7 +74,7 @@ class CollectionController {
|
|||
return res.status(500).send('Book already in collection')
|
||||
}
|
||||
collection.addBook(req.body.id)
|
||||
var jsonExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
const jsonExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
await this.db.updateEntity('collection', collection)
|
||||
SocketAuthority.emitter('collection_updated', jsonExpanded)
|
||||
res.json(jsonExpanded)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue