mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-17 08:11:43 +02:00
parent
e803dcd325
commit
061695f922
6 changed files with 157 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue