X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-live.ts;h=a1dd80d3c74bfe0d9cb6e5ce12f221ed2ad707e7;hb=fb7194043d0486ce0a6a40b2ffbdf32878c33a6f;hp=6929b96886cd48270c4c1aee80a4d393e2b140e5;hpb=c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-live.ts b/server/models/video/video-live.ts index 6929b9688..a1dd80d3c 100644 --- a/server/models/video/video-live.ts +++ b/server/models/video/video-live.ts @@ -1,14 +1,21 @@ import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' import { WEBSERVER } from '@server/initializers/constants' import { MVideoLive, MVideoLiveVideo } from '@server/types/models' -import { VideoLive } from '@shared/models/videos/video-live.model' +import { LiveVideo, VideoState } from '@shared/models' import { VideoModel } from './video' +import { VideoBlacklistModel } from './video-blacklist' @DefaultScope(() => ({ include: [ { model: VideoModel, - required: true + required: true, + include: [ + { + model: VideoBlacklistModel, + required: false + } + ] } ] })) @@ -23,10 +30,18 @@ import { VideoModel } from './video' }) export class VideoLiveModel extends Model { - @AllowNull(false) + @AllowNull(true) @Column(DataType.STRING) streamKey: string + @AllowNull(false) + @Column + perpetualLive: boolean + + @AllowNull(false) + @Column + saveReplay: boolean + @CreatedAt createdAt: Date @@ -49,7 +64,22 @@ export class VideoLiveModel extends Model { const query = { where: { streamKey - } + }, + include: [ + { + model: VideoModel.unscoped(), + required: true, + where: { + state: VideoState.WAITING_FOR_LIVE + }, + include: [ + { + model: VideoBlacklistModel.unscoped(), + required: false + } + ] + } + ] } return VideoLiveModel.findOne(query) @@ -65,7 +95,7 @@ export class VideoLiveModel extends Model { return VideoLiveModel.findOne(query) } - toFormattedJSON (): VideoLive { + toFormattedJSON (): LiveVideo { return { rtmpUrl: WEBSERVER.RTMP_URL, streamKey: this.streamKey