aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-03 15:33:30 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commit97969c4edf51b37eee691adba43368bb0fbb729b (patch)
treec1089f898fb936d75651630afcf406995eeb9fba /server/lib/video.ts
parentaf4ae64f6faf38f8179f2e07d3cd4ad60006be92 (diff)
downloadPeerTube-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.ts15
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'
4import { VideoModel } from '@server/models/video/video' 4import { VideoModel } from '@server/models/video/video'
5import { FilteredModelAttributes } from '@server/types' 5import { FilteredModelAttributes } from '@server/types'
6import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' 6import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models'
7import { ThumbnailType, VideoCreate, VideoPrivacy } from '@shared/models' 7import { ThumbnailType, VideoCreate, VideoPrivacy, VideoState } from '@shared/models'
8import { federateVideoIfNeeded } from './activitypub/videos' 8import { federateVideoIfNeeded } from './activitypub/videos'
9import { Notifier } from './notifier' 9import { Notifier } from './notifier'
10import { createVideoMiniatureFromExisting } from './thumbnail' 10import { createVideoMiniatureFromExisting } from './thumbnail'
@@ -81,8 +81,8 @@ async function setVideoTags (options: {
81 } 81 }
82} 82}
83 83
84async function publishAndFederateIfNeeded (video: MVideoUUID) { 84async 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