Add:API endpoint for opening RSS feed for collection #606 #1265

This commit is contained in:
advplyr
2022-12-26 17:48:39 -06:00
parent e803dcd325
commit 061695f922
6 changed files with 157 additions and 7 deletions

View File

@ -1,4 +1,3 @@
const Logger = require('../Logger')
const { getId } = require('../utils/index')
class Collection {
@ -46,6 +45,18 @@ class Collection {
return json
}
// Expanded and filtered out items not accessible to user
toJSONExpandedForUser(user, libraryItems) {
const json = this.toJSON()
json.books = json.books.map(libraryItemId => {
const libraryItem = libraryItems.find(li => li.id === libraryItemId)
return libraryItem ? libraryItem.toJSONExpanded() : null
}).filter(li => {
return li && user.checkCanAccessLibraryItem(li)
})
return json
}
construct(collection) {
this.id = collection.id
this.libraryId = collection.libraryId