aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-live.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-live.ts')
-rw-r--r--server/models/video/video-live.ts30
1 files changed, 26 insertions, 4 deletions
diff --git a/server/models/video/video-live.ts b/server/models/video/video-live.ts
index 6929b9688..8608bc84c 100644
--- a/server/models/video/video-live.ts
+++ b/server/models/video/video-live.ts
@@ -1,14 +1,21 @@
1import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' 1import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
2import { WEBSERVER } from '@server/initializers/constants' 2import { WEBSERVER } from '@server/initializers/constants'
3import { MVideoLive, MVideoLiveVideo } from '@server/types/models' 3import { MVideoLive, MVideoLiveVideo } from '@server/types/models'
4import { VideoLive } from '@shared/models/videos/video-live.model' 4import { LiveVideo, VideoState } from '@shared/models'
5import { VideoModel } from './video' 5import { VideoModel } from './video'
6import { VideoBlacklistModel } from './video-blacklist'
6 7
7@DefaultScope(() => ({ 8@DefaultScope(() => ({
8 include: [ 9 include: [
9 { 10 {
10 model: VideoModel, 11 model: VideoModel,
11 required: true 12 required: true,
13 include: [
14 {
15 model: VideoBlacklistModel,
16 required: false
17 }
18 ]
12 } 19 }
13 ] 20 ]
14})) 21}))
@@ -49,7 +56,22 @@ export class VideoLiveModel extends Model<VideoLiveModel> {
49 const query = { 56 const query = {
50 where: { 57 where: {
51 streamKey 58 streamKey
52 } 59 },
60 include: [
61 {
62 model: VideoModel.unscoped(),
63 required: true,
64 where: {
65 state: VideoState.WAITING_FOR_LIVE
66 },
67 include: [
68 {
69 model: VideoBlacklistModel.unscoped(),
70 required: false
71 }
72 ]
73 }
74 ]
53 } 75 }
54 76
55 return VideoLiveModel.findOne<MVideoLiveVideo>(query) 77 return VideoLiveModel.findOne<MVideoLiveVideo>(query)
@@ -65,7 +87,7 @@ export class VideoLiveModel extends Model<VideoLiveModel> {
65 return VideoLiveModel.findOne<MVideoLive>(query) 87 return VideoLiveModel.findOne<MVideoLive>(query)
66 } 88 }
67 89
68 toFormattedJSON (): VideoLive { 90 toFormattedJSON (): LiveVideo {
69 return { 91 return {
70 rtmpUrl: WEBSERVER.RTMP_URL, 92 rtmpUrl: WEBSERVER.RTMP_URL,
71 streamKey: this.streamKey 93 streamKey: this.streamKey