setDefaultVideosSort,
videosCustomGetValidator,
videosGetValidator,
+ videoSourceGetValidator,
videosRemoveValidator,
videosSortValidator
} from '../../../middlewares'
asyncMiddleware(videosGetValidator),
asyncMiddleware(getVideoDescription)
)
+
+videosRouter.get('/:id/source',
+ openapiOperationDoc({ operationId: 'getVideoSource' }),
+ authenticate,
+ asyncMiddleware(videoSourceGetValidator),
+ getVideoSource
+)
+
videosRouter.get('/:id',
openapiOperationDoc({ operationId: 'getVideo' }),
optionalAuthenticate,
asyncMiddleware(videosCustomGetValidator('for-api')),
asyncMiddleware(checkVideoFollowConstraints),
- getVideo
+ asyncMiddleware(getVideo)
)
videosRouter.delete('/:id',
res.json(VIDEO_PRIVACIES)
}
-function getVideo (_req: express.Request, res: express.Response) {
- const video = res.locals.videoAPI
+async function getVideo (_req: express.Request, res: express.Response) {
+ const videoId = res.locals.videoAPI.id
+ const userId = res.locals.oauth?.token.User.id
+
+ const video = await Hooks.wrapObject(res.locals.videoAPI, 'filter:api.video.get.result', { id: videoId, userId })
if (video.isOutdated()) {
- JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } })
+ JobQueue.Instance.createJobAsync({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } })
}
return res.json(video.toFormattedDetailsJSON())
return res.json({ description })
}
+function getVideoSource (req: express.Request, res: express.Response) {
+ return res.json(res.locals.videoSource.toFormattedJSON())
+}
+
async function listVideos (req: express.Request, res: express.Response) {
const serverActor = await getServerActor()