mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-12-02 13:14:07 +01:00
1 parent
e803dcd325
commit
061695f922
6 files changed
+157
-7
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user