mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-09 21:39:37 +00:00
Update author API endpoints to load library items from DB
This commit is contained in:
parent
56e3449db6
commit
345ff1aa66
5 changed files with 80 additions and 22 deletions
|
|
@ -357,5 +357,21 @@ module.exports = {
|
|||
return oldLibraryItem
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get library items for an author, optional use user permissions
|
||||
* @param {oldAuthor} author
|
||||
* @param {[oldUser]} user
|
||||
* @param {number} limit
|
||||
* @param {number} offset
|
||||
* @returns {object} { libraryItems:LibraryItem[], count:number }
|
||||
*/
|
||||
async getLibraryItemsForAuthor(author, user, limit, offset) {
|
||||
const { libraryItems, count } = await libraryItemsBookFilters.getFilteredLibraryItems(author.libraryId, user, 'authors', author.id, 'addedAt', true, false, [], limit, offset)
|
||||
return {
|
||||
count,
|
||||
libraryItems
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,8 @@ module.exports = {
|
|||
getUserPermissionBookWhereQuery(user) {
|
||||
const bookWhere = []
|
||||
const replacements = {}
|
||||
if (!user) return { bookWhere, replacements }
|
||||
|
||||
if (!user.canAccessExplicitContent) {
|
||||
bookWhere.push({
|
||||
explicit: false
|
||||
|
|
@ -325,7 +327,7 @@ module.exports = {
|
|||
/**
|
||||
* Get library items for book media type using filter and sort
|
||||
* @param {string} libraryId
|
||||
* @param {oldUser} user
|
||||
* @param {[oldUser]} user
|
||||
* @param {[string]} filterGroup
|
||||
* @param {[string]} filterValue
|
||||
* @param {string} sortBy
|
||||
|
|
@ -467,7 +469,7 @@ module.exports = {
|
|||
isInvalid: true
|
||||
}
|
||||
]
|
||||
} else if (filterGroup === 'progress') {
|
||||
} else if (filterGroup === 'progress' && user) {
|
||||
bookIncludes.push({
|
||||
model: Database.models.mediaProgress,
|
||||
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue