]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/live.ts
Add ability to filter my imports by target URL
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / live.ts
index efafe64e9af7d6c15611d8ad3b8c56fca2497a4b..8b8cacff99c8304621c01326cb8b81bdb1a46550 100644 (file)
@@ -1,6 +1,5 @@
 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'
@@ -10,8 +9,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'
@@ -83,7 +82,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 +134,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: {