1
0
Fork 0

Fix handling broken lives

We want the latest session that may already be finished
This commit is contained in:
Chocobozzz 2022-07-12 16:30:59 +02:00
parent 4ddb53f65d
commit 46f7cd6837
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 10 additions and 1 deletions

View file

@ -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) {

View file

@ -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