X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideos%2Flive.ts;h=49cabb6f3a256d045d4c1cd5efb0d1ca83311f1e;hb=01dd04cd5ab7b55d2a9af7d0ebf405bee9579b09;hp=ed4da8f479ad3154bd545e57b90d88872256b7fe;hpb=c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index ed4da8f47..49cabb6f3 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts @@ -1,7 +1,5 @@ -import * as express from 'express' +import express from 'express' import { createReqFiles } from '@server/helpers/express-utils' -import { buildUUID, uuidToShort } from '@server/helpers/uuid' -import { CONFIG } from '@server/initializers/config' import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' @@ -10,8 +8,8 @@ import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } fro import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live' import { VideoLiveModel } from '@server/models/video/video-live' import { MVideoDetails, MVideoFullLight } from '@server/types/models' -import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { buildUUID, uuidToShort } from '@shared/extra-utils' +import { HttpStatusCode, LiveVideoCreate, LiveVideoUpdate, VideoState } from '@shared/models' import { logger } from '../../../helpers/logger' import { sequelizeTypescript } from '../../../initializers/database' import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' @@ -20,14 +18,7 @@ import { VideoModel } from '../../../models/video/video' const liveRouter = express.Router() -const reqVideoFileLive = createReqFiles( - [ 'thumbnailfile', 'previewfile' ], - MIMETYPES.IMAGE.MIMETYPE_EXT, - { - thumbnailfile: CONFIG.STORAGE.TMP_DIR, - previewfile: CONFIG.STORAGE.TMP_DIR - } -) +const reqVideoFileLive = createReqFiles([ 'thumbnailfile', 'previewfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) liveRouter.post('/live', authenticate, @@ -39,7 +30,7 @@ liveRouter.post('/live', liveRouter.get('/live/:videoId', authenticate, asyncMiddleware(videoLiveGetValidator), - asyncRetryTransactionMiddleware(getLiveVideo) + getLiveVideo ) liveRouter.put('/live/:videoId', @@ -57,7 +48,7 @@ export { // --------------------------------------------------------------------------- -async function getLiveVideo (req: express.Request, res: express.Response) { +function getLiveVideo (req: express.Request, res: express.Response) { const videoLive = res.locals.videoLive return res.json(videoLive.toFormattedJSON()) @@ -83,7 +74,9 @@ async function addLiveVideo (req: express.Request, res: express.Response) { const videoInfo: LiveVideoCreate = req.body // Prepare data so we don't block the transaction - const videoData = buildLocalVideoFromReq(videoInfo, res.locals.videoChannel.id) + let videoData = buildLocalVideoFromReq(videoInfo, res.locals.videoChannel.id) + videoData = await Hooks.wrapObject(videoData, 'filter:api.video.live.video-attribute.result') + videoData.isLive = true videoData.state = VideoState.WAITING_FOR_LIVE videoData.duration = 0 @@ -133,7 +126,7 @@ async function addLiveVideo (req: express.Request, res: express.Response) { return { videoCreated } }) - Hooks.runAction('action:api.live-video.created', { video: videoCreated }) + Hooks.runAction('action:api.live-video.created', { video: videoCreated, req, res }) return res.json({ video: {