mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-10 00:18:06 +01:00
Fix:RSS feeds for collections not updating #2414
This commit is contained in:
parent
9720ba3eed
commit
fae383a045
@ -103,19 +103,29 @@ class RssFeedManager {
|
|||||||
await Database.updateFeed(feed)
|
await Database.updateFeed(feed)
|
||||||
}
|
}
|
||||||
} else if (feed.entityType === 'collection') {
|
} else if (feed.entityType === 'collection') {
|
||||||
const collection = await Database.collectionModel.findByPk(feed.entityId)
|
const collection = await Database.collectionModel.findByPk(feed.entityId, {
|
||||||
|
include: Database.collectionBookModel
|
||||||
|
})
|
||||||
if (collection) {
|
if (collection) {
|
||||||
const collectionExpanded = await collection.getOldJsonExpanded()
|
const collectionExpanded = await collection.getOldJsonExpanded()
|
||||||
|
|
||||||
// Find most recently updated item in collection
|
// Find most recently updated item in collection
|
||||||
let mostRecentlyUpdatedAt = collectionExpanded.lastUpdate
|
let mostRecentlyUpdatedAt = collectionExpanded.lastUpdate
|
||||||
|
// Check for most recently updated book
|
||||||
collectionExpanded.books.forEach((libraryItem) => {
|
collectionExpanded.books.forEach((libraryItem) => {
|
||||||
if (libraryItem.media.tracks.length && libraryItem.updatedAt > mostRecentlyUpdatedAt) {
|
if (libraryItem.media.tracks.length && libraryItem.updatedAt > mostRecentlyUpdatedAt) {
|
||||||
mostRecentlyUpdatedAt = libraryItem.updatedAt
|
mostRecentlyUpdatedAt = libraryItem.updatedAt
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Check for most recently added collection book
|
||||||
|
collection.collectionBooks.forEach((collectionBook) => {
|
||||||
|
if (collectionBook.createdAt.valueOf() > mostRecentlyUpdatedAt) {
|
||||||
|
mostRecentlyUpdatedAt = collectionBook.createdAt.valueOf()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const hasBooksRemoved = collection.collectionBooks.length < feed.episodes.length
|
||||||
|
|
||||||
if (!feed.entityUpdatedAt || mostRecentlyUpdatedAt > feed.entityUpdatedAt) {
|
if (!feed.entityUpdatedAt || hasBooksRemoved || mostRecentlyUpdatedAt > feed.entityUpdatedAt) {
|
||||||
Logger.debug(`[RssFeedManager] Updating RSS feed for collection "${collection.name}"`)
|
Logger.debug(`[RssFeedManager] Updating RSS feed for collection "${collection.name}"`)
|
||||||
|
|
||||||
feed.updateFromCollection(collectionExpanded)
|
feed.updateFromCollection(collectionExpanded)
|
||||||
|
@ -108,7 +108,7 @@ class Feed extends Model {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all library item ids that have an open feed (used in library filter)
|
* Find all library item ids that have an open feed (used in library filter)
|
||||||
* @returns {Promise<Array<String>>} array of library item ids
|
* @returns {Promise<string[]>} array of library item ids
|
||||||
*/
|
*/
|
||||||
static async findAllLibraryItemIds() {
|
static async findAllLibraryItemIds() {
|
||||||
const feeds = await this.findAll({
|
const feeds = await this.findAll({
|
||||||
@ -122,8 +122,8 @@ class Feed extends Model {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find feed where and return oldFeed
|
* Find feed where and return oldFeed
|
||||||
* @param {object} where sequelize where object
|
* @param {Object} where sequelize where object
|
||||||
* @returns {Promise<objects.Feed>} oldFeed
|
* @returns {Promise<oldFeed>} oldFeed
|
||||||
*/
|
*/
|
||||||
static async findOneOld(where) {
|
static async findOneOld(where) {
|
||||||
if (!where) return null
|
if (!where) return null
|
||||||
@ -140,7 +140,7 @@ class Feed extends Model {
|
|||||||
/**
|
/**
|
||||||
* Find feed and return oldFeed
|
* Find feed and return oldFeed
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @returns {Promise<objects.Feed>} oldFeed
|
* @returns {Promise<oldFeed>} oldFeed
|
||||||
*/
|
*/
|
||||||
static async findByPkOld(id) {
|
static async findByPkOld(id) {
|
||||||
if (!id) return null
|
if (!id) return null
|
||||||
|
Loading…
Reference in New Issue
Block a user