From af4ae64f6faf38f8179f2e07d3cd4ad60006be92 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 2 Nov 2020 15:43:44 +0100 Subject: Begin live tests --- server/controllers/activitypub/client.ts | 2 +- server/controllers/api/videos/index.ts | 2 +- server/controllers/api/videos/live.ts | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 1da44d096..df2a01d2c 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -223,7 +223,7 @@ function getAccountVideoRateFactory (rateType: VideoRateType) { async function videoController (req: express.Request, res: express.Response) { // We need more attributes - const video = await VideoModel.loadForGetAPI({ id: res.locals.onlyVideoWithRights.id }) as MVideoAPWithoutCaption + const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(res.locals.onlyVideoWithRights.id) if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6357062bc..50e769e77 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -189,7 +189,7 @@ async function addVideo (req: express.Request, res: express.Response) { videoData.state = CONFIG.TRANSCODING.ENABLED ? VideoState.TO_TRANSCODE : VideoState.PUBLISHED videoData.duration = videoPhysicalFile['duration'] // duration was added by a previous middleware - const video = new VideoModel(videoData) as MVideoDetails + const video = new VideoModel(videoData) as MVideoFullLight video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object const videoFile = new VideoFileModel({ diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index be46fb1c6..f980c7730 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts @@ -4,6 +4,7 @@ import { createReqFiles } from '@server/helpers/express-utils' import { CONFIG } from '@server/initializers/config' import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' +import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live' import { VideoLiveModel } from '@server/models/video/video-live' @@ -63,10 +64,13 @@ async function getLiveVideo (req: express.Request, res: express.Response) { async function updateLiveVideo (req: express.Request, res: express.Response) { const body: LiveVideoUpdate = req.body + const video = res.locals.videoAll const videoLive = res.locals.videoLive videoLive.saveReplay = body.saveReplay || false - await videoLive.save() + video.VideoLive = await videoLive.save() + + await federateVideoIfNeeded(video, false) return res.sendStatus(204) } @@ -113,10 +117,12 @@ async function addLiveVideo (req: express.Request, res: express.Response) { videoCreated.VideoChannel = res.locals.videoChannel videoLive.videoId = videoCreated.id - await videoLive.save(sequelizeOptions) + videoCreated.VideoLive = await videoLive.save(sequelizeOptions) await setVideoTags({ video, tags: videoInfo.tags, transaction: t }) + await federateVideoIfNeeded(videoCreated, true, t) + logger.info('Video live %s with uuid %s created.', videoInfo.name, videoCreated.uuid) return { videoCreated } -- cgit v1.2.3