Remove max duration/filesize constraints

pull/128/head
Chocobozzz 2017-11-28 14:51:00 +01:00
parent 7dbdc3bace
commit c60774b05b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 9 additions and 32 deletions

View File

@ -126,7 +126,7 @@ const CONSTRAINTS_FIELDS = {
DESCRIPTION: { min: 3, max: 3000 }, // Length DESCRIPTION: { min: 3, max: 3000 }, // Length
EXTNAME: [ '.mp4', '.ogv', '.webm' ], 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 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 TAGS: { min: 0, max: 5 }, // Number of total tags
TAG: { min: 2, max: 30 }, // Length TAG: { min: 2, max: 30 }, // Length
THUMBNAIL: { min: 2, max: 30 }, THUMBNAIL: { min: 2, max: 30 },
@ -134,7 +134,7 @@ const CONSTRAINTS_FIELDS = {
VIEWS: { min: 0 }, VIEWS: { min: 0 },
LIKES: { min: 0 }, LIKES: { min: 0 },
DISLIKES: { 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 URL: { min: 3, max: 2000 } // Length
}, },
ACCOUNTS: { 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 SERVER_ACCOUNT_NAME = 'peertube'
const ACTIVITY_PUB = { const ACTIVITY_PUB = {
@ -242,7 +236,9 @@ const ACTIVITY_PUB = {
// Number of points we add/remove from a friend after a successful/bad request // Number of points we add/remove from a friend after a successful/bad request
const SERVERS_SCORE = { const SERVERS_SCORE = {
PENALTY: -10, PENALTY: -10,
BONUS: 10 BONUS: 10,
BASE: 100,
MAX: 1000
} }
const FOLLOW_STATES: { [ id: string ]: FollowState } = { const FOLLOW_STATES: { [ id: string ]: FollowState } = {
@ -323,8 +319,7 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
// Special constants for a test instance // Special constants for a test instance
if (isTestInstance() === true) { if (isTestInstance() === true) {
CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14 SERVERS_SCORE.BASE = 20
FRIEND_SCORE.BASE = 20
JOBS_FETCHING_INTERVAL = 1000 JOBS_FETCHING_INTERVAL = 1000
REMOTE_SCHEME.HTTP = 'http' REMOTE_SCHEME.HTTP = 'http'
REMOTE_SCHEME.WS = 'ws' REMOTE_SCHEME.WS = 'ws'
@ -341,7 +336,6 @@ export {
CONFIG, CONFIG,
CONSTRAINTS_FIELDS, CONSTRAINTS_FIELDS,
EMBED_SIZE, EMBED_SIZE,
FRIEND_SCORE,
JOB_STATES, JOB_STATES,
JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCH_LIMIT_PER_CYCLE,
JOBS_FETCHING_INTERVAL, JOBS_FETCHING_INTERVAL,

View File

@ -6,7 +6,6 @@ import {
isVideoAbuseReasonValid, isVideoAbuseReasonValid,
isVideoCategoryValid, isVideoCategoryValid,
isVideoDescriptionValid, isVideoDescriptionValid,
isVideoDurationValid,
isVideoExist, isVideoExist,
isVideoFile, isVideoFile,
isVideoLanguageValid, isVideoLanguageValid,
@ -82,14 +81,6 @@ const videosAddValidator = [
return 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 videoFile['duration'] = duration
return next() return next()

View File

@ -1,6 +1,6 @@
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { isHostValid, logger } from '../../helpers' import { isHostValid, logger } from '../../helpers'
import { FRIEND_SCORE, SERVERS_SCORE } from '../../initializers' import { SERVERS_SCORE } from '../../initializers'
import { addMethodsToModel } from '../utils' import { addMethodsToModel } from '../utils'
import { ServerAttributes, ServerInstance, ServerMethods } from './server-interface' import { ServerAttributes, ServerInstance, ServerMethods } from './server-interface'
@ -22,11 +22,11 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
}, },
score: { score: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
defaultValue: FRIEND_SCORE.BASE, defaultValue: SERVERS_SCORE.BASE,
allowNull: false, allowNull: false,
validate: { validate: {
isInt: true, isInt: true,
max: FRIEND_SCORE.MAX max: SERVERS_SCORE.MAX
} }
} }
}, },

View File

@ -333,14 +333,6 @@ describe('Test videos API validator', function () {
await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 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 () { it('Should succeed with the correct parameters', async function () {
this.timeout(10000) this.timeout(10000)