import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
import {
- CONFIG,
- IMAGE_MIMETYPE_EXT,
+ CONFIG, MIMETYPES,
PREVIEWS_SIZE,
sequelizeTypescript,
THUMBNAILS_SIZE,
VIDEO_CATEGORIES,
VIDEO_LANGUAGES,
VIDEO_LICENCES,
- VIDEO_MIMETYPE_EXT,
VIDEO_PRIVACIES
} from '../../../initializers'
import {
asyncMiddleware,
asyncRetryTransactionMiddleware,
authenticate,
+ checkVideoFollowConstraints,
commonVideosFiltersValidator,
optionalAuthenticate,
paginationValidator,
import { videoCaptionsRouter } from './captions'
import { videoImportsRouter } from './import'
import { resetSequelizeInstance } from '../../../helpers/database-utils'
-import { rename } from 'fs-extra'
+import { move } from 'fs-extra'
import { watchingRouter } from './watching'
const auditLogger = auditLoggerFactory('videos')
const reqVideoFileAdd = createReqFiles(
[ 'videofile', 'thumbnailfile', 'previewfile' ],
- Object.assign({}, VIDEO_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT),
+ Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT),
{
- videofile: CONFIG.STORAGE.VIDEOS_DIR,
- thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR,
- previewfile: CONFIG.STORAGE.PREVIEWS_DIR
+ videofile: CONFIG.STORAGE.TMP_DIR,
+ thumbnailfile: CONFIG.STORAGE.TMP_DIR,
+ previewfile: CONFIG.STORAGE.TMP_DIR
}
)
const reqVideoFileUpdate = createReqFiles(
[ 'thumbnailfile', 'previewfile' ],
- IMAGE_MIMETYPE_EXT,
+ MIMETYPES.IMAGE.MIMETYPE_EXT,
{
- thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR,
- previewfile: CONFIG.STORAGE.PREVIEWS_DIR
+ thumbnailfile: CONFIG.STORAGE.TMP_DIR,
+ previewfile: CONFIG.STORAGE.TMP_DIR
}
)
videosRouter.get('/:id',
optionalAuthenticate,
asyncMiddleware(videosGetValidator),
+ asyncMiddleware(checkVideoFollowConstraints),
getVideo
)
videosRouter.post('/:id/views',
// Move physical file
const videoDir = CONFIG.STORAGE.VIDEOS_DIR
const destination = join(videoDir, video.getVideoFilename(videoFile))
- await rename(videoPhysicalFile.path, destination)
+ await move(videoPhysicalFile.path, destination)
// This is important in case if there is another attempt in the retry process
videoPhysicalFile.filename = video.getVideoFilename(videoFile)
videoPhysicalFile.path = destination
function getVideo (req: express.Request, res: express.Response) {
const videoInstance = res.locals.video
+ if (videoInstance.isOutdated()) {
+ JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', videoUrl: videoInstance.url } })
+ .catch(err => logger.error('Cannot create AP refresher job for video %s.', videoInstance.url, { err }))
+ }
+
return res.json(videoInstance.toFormattedDetailsJSON())
}
])
const serverActor = await getServerActor()
-
await sendCreateView(serverActor, videoInstance, undefined)
return res.status(204).end()
return res.json({ description })
}
-async function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
+async function listVideos (req: express.Request, res: express.Response) {
const resultList = await VideoModel.listForApi({
start: req.query.start,
count: req.query.count,