Refactor RssFeedManager to use new model when closing feeds, fix close series feed when series is removed, update RssFeedManager to singleton

This commit is contained in:
advplyr 2024-12-15 12:37:01 -06:00
parent e50bd93958
commit 4c68ad46f4
10 changed files with 105 additions and 78 deletions

View file

@ -124,12 +124,18 @@ class Feed extends Model {
})
}
static removeById(feedId) {
return this.destroy({
where: {
id: feedId
}
})
/**
* @param {string} feedId
* @returns {Promise<boolean>} - true if feed was removed
*/
static async removeById(feedId) {
return (
(await this.destroy({
where: {
id: feedId
}
})) > 0
)
}
/**
@ -163,22 +169,6 @@ class Feed extends Model {
return this.getOldFeed(feedExpanded)
}
/**
* Find feed and return oldFeed
* @param {string} id
* @returns {Promise<oldFeed>} oldFeed
*/
static async findByPkOld(id) {
if (!id) return null
const feedExpanded = await this.findByPk(id, {
include: {
model: this.sequelize.models.feedEpisode
}
})
if (!feedExpanded) return null
return this.getOldFeed(feedExpanded)
}
static async fullCreateFromOld(oldFeed) {
const feedObj = this.getFromOld(oldFeed)
const newFeed = await this.create(feedObj)