1
0
Fork 0

Add check constraints live tests

This commit is contained in:
Chocobozzz 2020-11-03 15:33:30 +01:00 committed by Chocobozzz
parent af4ae64f6f
commit 97969c4edf
13 changed files with 229 additions and 37 deletions

View file

@ -4,7 +4,7 @@ import { TagModel } from '@server/models/video/tag'
import { VideoModel } from '@server/models/video/video'
import { FilteredModelAttributes } from '@server/types'
import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models'
import { ThumbnailType, VideoCreate, VideoPrivacy } from '@shared/models'
import { ThumbnailType, VideoCreate, VideoPrivacy, VideoState } from '@shared/models'
import { federateVideoIfNeeded } from './activitypub/videos'
import { Notifier } from './notifier'
import { createVideoMiniatureFromExisting } from './thumbnail'
@ -81,8 +81,8 @@ async function setVideoTags (options: {
}
}
async function publishAndFederateIfNeeded (video: MVideoUUID) {
const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => {
async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) {
const result = await sequelizeTypescript.transaction(async t => {
// Maybe the video changed in database, refresh it
const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
// Video does not exist anymore
@ -92,14 +92,15 @@ async function publishAndFederateIfNeeded (video: MVideoUUID) {
const videoPublished = await videoDatabase.publishIfNeededAndSave(t)
// If the video was not published, we consider it is a new one for other instances
await federateVideoIfNeeded(videoDatabase, videoPublished, t)
// Live videos are always federated, so it's not a new video
await federateVideoIfNeeded(videoDatabase, !wasLive && videoPublished, t)
return { videoDatabase, videoPublished }
})
if (videoPublished) {
Notifier.Instance.notifyOnNewVideoIfNeeded(videoDatabase)
Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(videoDatabase)
if (result?.videoPublished) {
Notifier.Instance.notifyOnNewVideoIfNeeded(result.videoDatabase)
Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(result.videoDatabase)
}
}