diff options
author | Chocobozzz <me@florianbigard.com> | 2020-09-25 10:04:21 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | a5cf76afa378aae81af2a9b0ce548e5d2582f832 (patch) | |
tree | 58da320232bee7c9656774c5d6811e82bbf6c696 /server/models/video/video-live.ts | |
parent | de6310b2fcbb8a6b79c546b23dfa1920724faaa7 (diff) | |
download | PeerTube-a5cf76afa378aae81af2a9b0ce548e5d2582f832.tar.gz PeerTube-a5cf76afa378aae81af2a9b0ce548e5d2582f832.tar.zst PeerTube-a5cf76afa378aae81af2a9b0ce548e5d2582f832.zip |
Add watch messages if live has not started
Diffstat (limited to 'server/models/video/video-live.ts')
-rw-r--r-- | server/models/video/video-live.ts | 30 |
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 @@ | |||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' | 1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' |
2 | import { WEBSERVER } from '@server/initializers/constants' | 2 | import { WEBSERVER } from '@server/initializers/constants' |
3 | import { MVideoLive, MVideoLiveVideo } from '@server/types/models' | 3 | import { MVideoLive, MVideoLiveVideo } from '@server/types/models' |
4 | import { VideoLive } from '@shared/models/videos/video-live.model' | 4 | import { LiveVideo, VideoState } from '@shared/models' |
5 | import { VideoModel } from './video' | 5 | import { VideoModel } from './video' |
6 | import { 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 |