X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideo-imports.ts;h=0063d3337fd96749c65396f3514363577e9587e1;hb=f2eb23cd87cf32b8fe545178143b5f49e06a58da;hp=c571f5dddccfb701dddd78ae899a8bc4e0873033;hpb=7024e9120b381b5b3201212f5a18f5cdc14e15ff;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/video-imports.ts b/server/helpers/custom-validators/video-imports.ts index c571f5ddd..0063d3337 100644 --- a/server/helpers/custom-validators/video-imports.ts +++ b/server/helpers/custom-validators/video-imports.ts @@ -4,6 +4,7 @@ import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initia import { exists, isFileValid } from './misc' import * as express from 'express' import { VideoImportModel } from '../../models/video/video-import' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' function isVideoImportTargetUrlValid (url: string) { const isURLOptions = { @@ -23,8 +24,10 @@ function isVideoImportStateValid (value: any) { return exists(value) && VIDEO_IMPORT_STATES[value] !== undefined } -const videoTorrentImportTypes = Object.keys(MIMETYPES.TORRENT.MIMETYPE_EXT).map(m => `(${m})`) -const videoTorrentImportRegex = videoTorrentImportTypes.join('|') +const videoTorrentImportRegex = Object.keys(MIMETYPES.TORRENT.MIMETYPE_EXT) + .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream + .map(m => `(${m})`) + .join('|') function isVideoImportTorrentFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) { return isFileValid(files, videoTorrentImportRegex, 'torrentfile', CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true) } @@ -33,7 +36,7 @@ async function doesVideoImportExist (id: number, res: express.Response) { const videoImport = await VideoImportModel.loadAndPopulateVideo(id) if (!videoImport) { - res.status(404) + res.status(HttpStatusCode.NOT_FOUND_404) .json({ error: 'Video import not found' }) .end()