From c60774b05b12d262ed27d8efeb0905ac283eeebb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Nov 2017 14:51:00 +0100 Subject: [PATCH] Remove max duration/filesize constraints --- server/initializers/constants.ts | 18 ++++++------------ server/middlewares/validators/videos.ts | 9 --------- server/models/server/server.ts | 6 +++--- server/tests/api/check-params/videos.ts | 8 -------- 4 files changed, 9 insertions(+), 32 deletions(-) diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index f09422ffd..82373ba84 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -126,7 +126,7 @@ const CONSTRAINTS_FIELDS = { DESCRIPTION: { min: 3, max: 3000 }, // Length EXTNAME: [ '.mp4', '.ogv', '.webm' ], INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 - DURATION: { min: 1, max: 7200 }, // Number + DURATION: { min: 1 }, // Number TAGS: { min: 0, max: 5 }, // Number of total tags TAG: { min: 2, max: 30 }, // Length THUMBNAIL: { min: 2, max: 30 }, @@ -134,7 +134,7 @@ const CONSTRAINTS_FIELDS = { VIEWS: { min: 0 }, LIKES: { min: 0 }, DISLIKES: { min: 0 }, - FILE_SIZE: { min: 10, max: 1024 * 1024 * 1024 * 10 /* 10Go */ }, + FILE_SIZE: { min: 10 }, URL: { min: 3, max: 2000 } // Length }, ACCOUNTS: { @@ -216,12 +216,6 @@ const VIDEO_MIMETYPE_EXT = { // --------------------------------------------------------------------------- -// Score a server has when we create it as a friend -const FRIEND_SCORE = { - BASE: 100, - MAX: 1000 -} - const SERVER_ACCOUNT_NAME = 'peertube' const ACTIVITY_PUB = { @@ -242,7 +236,9 @@ const ACTIVITY_PUB = { // Number of points we add/remove from a friend after a successful/bad request const SERVERS_SCORE = { PENALTY: -10, - BONUS: 10 + BONUS: 10, + BASE: 100, + MAX: 1000 } const FOLLOW_STATES: { [ id: string ]: FollowState } = { @@ -323,8 +319,7 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '' // Special constants for a test instance if (isTestInstance() === true) { - CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14 - FRIEND_SCORE.BASE = 20 + SERVERS_SCORE.BASE = 20 JOBS_FETCHING_INTERVAL = 1000 REMOTE_SCHEME.HTTP = 'http' REMOTE_SCHEME.WS = 'ws' @@ -341,7 +336,6 @@ export { CONFIG, CONSTRAINTS_FIELDS, EMBED_SIZE, - FRIEND_SCORE, JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL, diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 3cbf98312..52b4475ce 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -6,7 +6,6 @@ import { isVideoAbuseReasonValid, isVideoCategoryValid, isVideoDescriptionValid, - isVideoDurationValid, isVideoExist, isVideoFile, isVideoLanguageValid, @@ -82,14 +81,6 @@ const videosAddValidator = [ return } - if (!isVideoDurationValid('' + duration)) { - return res.status(400) - .json({ - error: 'Duration of the video file is too big (max: ' + CONSTRAINTS_FIELDS.VIDEOS.DURATION.max + 's).' - }) - .end() - } - videoFile['duration'] = duration return next() diff --git a/server/models/server/server.ts b/server/models/server/server.ts index fcd7be090..ebd216b08 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts @@ -1,6 +1,6 @@ import * as Sequelize from 'sequelize' import { isHostValid, logger } from '../../helpers' -import { FRIEND_SCORE, SERVERS_SCORE } from '../../initializers' +import { SERVERS_SCORE } from '../../initializers' import { addMethodsToModel } from '../utils' import { ServerAttributes, ServerInstance, ServerMethods } from './server-interface' @@ -22,11 +22,11 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da }, score: { type: DataTypes.INTEGER, - defaultValue: FRIEND_SCORE.BASE, + defaultValue: SERVERS_SCORE.BASE, allowNull: false, validate: { isInt: true, - max: FRIEND_SCORE.MAX + max: SERVERS_SCORE.MAX } } }, diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 7f5609784..2962f5640 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -333,14 +333,6 @@ describe('Test videos API validator', function () { await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) }) - it('Should fail with a too big duration', async function () { - const fields = getCompleteVideoUploadAttributes() - const attaches = { - 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') - } - await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) - }) - it('Should succeed with the correct parameters', async function () { this.timeout(10000)