mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-19 00:18:56 +01:00
Set podcastId when mediaProgress is created
This commit is contained in:
parent
f1de307bf9
commit
da8fd2d9d5
@ -634,6 +634,7 @@ class User extends Model {
|
|||||||
/** @type {import('./MediaProgress')|null} */
|
/** @type {import('./MediaProgress')|null} */
|
||||||
let mediaProgress = null
|
let mediaProgress = null
|
||||||
let mediaItemId = null
|
let mediaItemId = null
|
||||||
|
let podcastId = null
|
||||||
if (progressPayload.episodeId) {
|
if (progressPayload.episodeId) {
|
||||||
const podcastEpisode = await this.sequelize.models.podcastEpisode.findByPk(progressPayload.episodeId, {
|
const podcastEpisode = await this.sequelize.models.podcastEpisode.findByPk(progressPayload.episodeId, {
|
||||||
attributes: ['id', 'podcastId'],
|
attributes: ['id', 'podcastId'],
|
||||||
@ -662,6 +663,7 @@ class User extends Model {
|
|||||||
}
|
}
|
||||||
mediaItemId = podcastEpisode.id
|
mediaItemId = podcastEpisode.id
|
||||||
mediaProgress = podcastEpisode.mediaProgresses?.[0]
|
mediaProgress = podcastEpisode.mediaProgresses?.[0]
|
||||||
|
podcastId = podcastEpisode.podcastId
|
||||||
} else {
|
} else {
|
||||||
const libraryItem = await this.sequelize.models.libraryItem.findByPk(progressPayload.libraryItemId, {
|
const libraryItem = await this.sequelize.models.libraryItem.findByPk(progressPayload.libraryItemId, {
|
||||||
attributes: ['id', 'mediaId', 'mediaType'],
|
attributes: ['id', 'mediaId', 'mediaType'],
|
||||||
@ -694,6 +696,7 @@ class User extends Model {
|
|||||||
const newMediaProgressPayload = {
|
const newMediaProgressPayload = {
|
||||||
userId: this.id,
|
userId: this.id,
|
||||||
mediaItemId,
|
mediaItemId,
|
||||||
|
podcastId,
|
||||||
mediaItemType: progressPayload.episodeId ? 'podcastEpisode' : 'book',
|
mediaItemType: progressPayload.episodeId ? 'podcastEpisode' : 'book',
|
||||||
duration: isNullOrNaN(progressPayload.duration) ? 0 : Number(progressPayload.duration),
|
duration: isNullOrNaN(progressPayload.duration) ? 0 : Number(progressPayload.duration),
|
||||||
currentTime: isNullOrNaN(progressPayload.currentTime) ? 0 : Number(progressPayload.currentTime),
|
currentTime: isNullOrNaN(progressPayload.currentTime) ? 0 : Number(progressPayload.currentTime),
|
||||||
|
Loading…
Reference in New Issue
Block a user