mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
PlaybackSession, Playlist, PlaylistMediaItem, Device data models
This commit is contained in:
parent
a1a923df94
commit
bed3758268
9 changed files with 231 additions and 25 deletions
|
|
@ -55,16 +55,16 @@ module.exports = (sequelize) => {
|
|||
MediaProgress.addHook('afterFind', findResult => {
|
||||
if (!Array.isArray(findResult)) findResult = [findResult]
|
||||
for (const instance of findResult) {
|
||||
if (instance.mediaItemType === 'book' && instance.book !== undefined) {
|
||||
instance.mediaItem = instance.book
|
||||
} else if (instance.mediaItemType === 'podcastEpisode' && instance.podcastEpisode !== undefined) {
|
||||
instance.mediaItem = instance.podcastEpisode
|
||||
if (instance.mediaItemType === 'book' && instance.Book !== undefined) {
|
||||
instance.MediaItem = instance.Book
|
||||
} else if (instance.mediaItemType === 'podcastEpisode' && instance.PodcastEpisode !== undefined) {
|
||||
instance.MediaItem = instance.PodcastEpisode
|
||||
}
|
||||
// To prevent mistakes:
|
||||
delete instance.book
|
||||
delete instance.dataValues.book
|
||||
delete instance.podcastEpisode
|
||||
delete instance.dataValues.podcastEpisode
|
||||
delete instance.Book
|
||||
delete instance.dataValues.Book
|
||||
delete instance.PodcastEpisode
|
||||
delete instance.dataValues.PodcastEpisode
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue