diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-03 15:33:30 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | 97969c4edf51b37eee691adba43368bb0fbb729b (patch) | |
tree | c1089f898fb936d75651630afcf406995eeb9fba /server/lib/video.ts | |
parent | af4ae64f6faf38f8179f2e07d3cd4ad60006be92 (diff) | |
download | PeerTube-97969c4edf51b37eee691adba43368bb0fbb729b.tar.gz PeerTube-97969c4edf51b37eee691adba43368bb0fbb729b.tar.zst PeerTube-97969c4edf51b37eee691adba43368bb0fbb729b.zip |
Add check constraints live tests
Diffstat (limited to 'server/lib/video.ts')
-rw-r--r-- | server/lib/video.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/lib/video.ts b/server/lib/video.ts index 81b7c4159..8d9918b2d 100644 --- a/server/lib/video.ts +++ b/server/lib/video.ts | |||
@@ -4,7 +4,7 @@ import { TagModel } from '@server/models/video/tag' | |||
4 | import { VideoModel } from '@server/models/video/video' | 4 | import { VideoModel } from '@server/models/video/video' |
5 | import { FilteredModelAttributes } from '@server/types' | 5 | import { FilteredModelAttributes } from '@server/types' |
6 | import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' | 6 | import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' |
7 | import { ThumbnailType, VideoCreate, VideoPrivacy } from '@shared/models' | 7 | import { ThumbnailType, VideoCreate, VideoPrivacy, VideoState } from '@shared/models' |
8 | import { federateVideoIfNeeded } from './activitypub/videos' | 8 | import { federateVideoIfNeeded } from './activitypub/videos' |
9 | import { Notifier } from './notifier' | 9 | import { Notifier } from './notifier' |
10 | import { createVideoMiniatureFromExisting } from './thumbnail' | 10 | import { createVideoMiniatureFromExisting } from './thumbnail' |
@@ -81,8 +81,8 @@ async function setVideoTags (options: { | |||
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | async function publishAndFederateIfNeeded (video: MVideoUUID) { | 84 | async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) { |
85 | const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => { | 85 | const result = await sequelizeTypescript.transaction(async t => { |
86 | // Maybe the video changed in database, refresh it | 86 | // Maybe the video changed in database, refresh it |
87 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) | 87 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
88 | // Video does not exist anymore | 88 | // Video does not exist anymore |
@@ -92,14 +92,15 @@ async function publishAndFederateIfNeeded (video: MVideoUUID) { | |||
92 | const videoPublished = await videoDatabase.publishIfNeededAndSave(t) | 92 | const videoPublished = await videoDatabase.publishIfNeededAndSave(t) |
93 | 93 | ||
94 | // If the video was not published, we consider it is a new one for other instances | 94 | // If the video was not published, we consider it is a new one for other instances |
95 | await federateVideoIfNeeded(videoDatabase, videoPublished, t) | 95 | // Live videos are always federated, so it's not a new video |
96 | await federateVideoIfNeeded(videoDatabase, !wasLive && videoPublished, t) | ||
96 | 97 | ||
97 | return { videoDatabase, videoPublished } | 98 | return { videoDatabase, videoPublished } |
98 | }) | 99 | }) |
99 | 100 | ||
100 | if (videoPublished) { | 101 | if (result?.videoPublished) { |
101 | Notifier.Instance.notifyOnNewVideoIfNeeded(videoDatabase) | 102 | Notifier.Instance.notifyOnNewVideoIfNeeded(result.videoDatabase) |
102 | Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(videoDatabase) | 103 | Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(result.videoDatabase) |
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||