Update share endpoint to return playback session, add get share file endpoint

This commit is contained in:
advplyr 2024-06-26 17:03:12 -05:00
parent 042035051d
commit 8cadaa57f6
6 changed files with 161 additions and 12 deletions

View file

@ -44,6 +44,41 @@ class MediaItemShare extends Model {
}
}
/**
*
* @param {string} mediaItemId
* @param {string} mediaItemType
* @returns {Promise<import('../objects/LibraryItem')>}
*/
static async getMediaItemsOldLibraryItem(mediaItemId, mediaItemType) {
if (mediaItemType === 'book') {
const book = await this.sequelize.models.book.findByPk(mediaItemId, {
include: [
{
model: this.sequelize.models.author,
through: {
attributes: []
}
},
{
model: this.sequelize.models.series,
through: {
attributes: ['sequence']
}
},
{
model: this.sequelize.models.libraryItem
}
]
})
const libraryItem = book.libraryItem
libraryItem.media = book
delete book.libraryItem
return this.sequelize.models.libraryItem.getOldLibraryItem(libraryItem)
}
return null
}
/**
*
* @param {import('sequelize').FindOptions} options