Fix handling broken lives
We want the latest session that may already be finished
This commit is contained in:
parent
4ddb53f65d
commit
46f7cd6837
2 changed files with 10 additions and 1 deletions
|
@ -395,7 +395,7 @@ class LiveManager {
|
|||
|
||||
const live = await VideoLiveModel.loadByVideoId(fullVideo.id)
|
||||
|
||||
const liveSession = liveSessionArg ?? await VideoLiveSessionModel.findCurrentSessionOf(fullVideo.id)
|
||||
const liveSession = liveSessionArg ?? await VideoLiveSessionModel.findLatestSessionOf(fullVideo.id)
|
||||
|
||||
// On server restart during a live
|
||||
if (!liveSession.endDate) {
|
||||
|
|
|
@ -107,6 +107,15 @@ export class VideoLiveSessionModel extends Model<Partial<AttributesOnly<VideoLiv
|
|||
})
|
||||
}
|
||||
|
||||
static findLatestSessionOf (videoId: number) {
|
||||
return VideoLiveSessionModel.findOne({
|
||||
where: {
|
||||
liveVideoId: videoId
|
||||
},
|
||||
order: [ [ 'startDate', 'DESC' ] ]
|
||||
})
|
||||
}
|
||||
|
||||
static listSessionsOfLiveForAPI (options: { videoId: number }) {
|
||||
const { videoId } = options
|
||||
|
||||
|
|
Loading…
Reference in a new issue