mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-05 02:34:56 +02:00
RSS feed for collection to update when any item in the collection is updated #606
This commit is contained in:
parent
9e4bc582cb
commit
315c83e4c3
4 changed files with 24 additions and 10 deletions
|
@ -52,11 +52,19 @@ class RssFeedManager {
|
|||
await this.db.updateEntity('feed', feed)
|
||||
}
|
||||
} else if (feed.entityType === 'collection') {
|
||||
// TODO: Also trigger an update if any item in the collection was updated
|
||||
const collection = this.db.collections.find(c => c.id === feed.entityId)
|
||||
if (collection) {
|
||||
const collectionExpanded = collection.toJSONExpanded(this.db.libraryItems)
|
||||
if (!feed.entityUpdatedAt || collection.lastUpdate > feed.entityUpdatedAt) {
|
||||
|
||||
// Find most recently updated item in collection
|
||||
let mostRecentlyUpdatedAt = collectionExpanded.lastUpdate
|
||||
collectionExpanded.books.forEach((libraryItem) => {
|
||||
if (libraryItem.media.tracks.length && libraryItem.updatedAt > mostRecentlyUpdatedAt) {
|
||||
mostRecentlyUpdatedAt = libraryItem.updatedAt
|
||||
}
|
||||
})
|
||||
|
||||
if (!feed.entityUpdatedAt || mostRecentlyUpdatedAt > feed.entityUpdatedAt) {
|
||||
Logger.debug(`[RssFeedManager] Updating RSS feed for collection "${collection.name}"`)
|
||||
|
||||
feed.updateFromCollection(collectionExpanded)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue