aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts18
-rw-r--r--server/middlewares/validators/videos.ts9
-rw-r--r--server/models/server/server.ts6
-rw-r--r--server/tests/api/check-params/videos.ts8
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 = {
126 DESCRIPTION: { min: 3, max: 3000 }, // Length 126 DESCRIPTION: { min: 3, max: 3000 }, // Length
127 EXTNAME: [ '.mp4', '.ogv', '.webm' ], 127 EXTNAME: [ '.mp4', '.ogv', '.webm' ],
128 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 128 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2
129 DURATION: { min: 1, max: 7200 }, // Number 129 DURATION: { min: 1 }, // Number
130 TAGS: { min: 0, max: 5 }, // Number of total tags 130 TAGS: { min: 0, max: 5 }, // Number of total tags
131 TAG: { min: 2, max: 30 }, // Length 131 TAG: { min: 2, max: 30 }, // Length
132 THUMBNAIL: { min: 2, max: 30 }, 132 THUMBNAIL: { min: 2, max: 30 },
@@ -134,7 +134,7 @@ const CONSTRAINTS_FIELDS = {
134 VIEWS: { min: 0 }, 134 VIEWS: { min: 0 },
135 LIKES: { min: 0 }, 135 LIKES: { min: 0 },
136 DISLIKES: { min: 0 }, 136 DISLIKES: { min: 0 },
137 FILE_SIZE: { min: 10, max: 1024 * 1024 * 1024 * 10 /* 10Go */ }, 137 FILE_SIZE: { min: 10 },
138 URL: { min: 3, max: 2000 } // Length 138 URL: { min: 3, max: 2000 } // Length
139 }, 139 },
140 ACCOUNTS: { 140 ACCOUNTS: {
@@ -216,12 +216,6 @@ const VIDEO_MIMETYPE_EXT = {
216 216
217// --------------------------------------------------------------------------- 217// ---------------------------------------------------------------------------
218 218
219// Score a server has when we create it as a friend
220const FRIEND_SCORE = {
221 BASE: 100,
222 MAX: 1000
223}
224
225const SERVER_ACCOUNT_NAME = 'peertube' 219const SERVER_ACCOUNT_NAME = 'peertube'
226 220
227const ACTIVITY_PUB = { 221const ACTIVITY_PUB = {
@@ -242,7 +236,9 @@ const ACTIVITY_PUB = {
242// Number of points we add/remove from a friend after a successful/bad request 236// Number of points we add/remove from a friend after a successful/bad request
243const SERVERS_SCORE = { 237const SERVERS_SCORE = {
244 PENALTY: -10, 238 PENALTY: -10,
245 BONUS: 10 239 BONUS: 10,
240 BASE: 100,
241 MAX: 1000
246} 242}
247 243
248const FOLLOW_STATES: { [ id: string ]: FollowState } = { 244const FOLLOW_STATES: { [ id: string ]: FollowState } = {
@@ -323,8 +319,7 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
323 319
324// Special constants for a test instance 320// Special constants for a test instance
325if (isTestInstance() === true) { 321if (isTestInstance() === true) {
326 CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14 322 SERVERS_SCORE.BASE = 20
327 FRIEND_SCORE.BASE = 20
328 JOBS_FETCHING_INTERVAL = 1000 323 JOBS_FETCHING_INTERVAL = 1000
329 REMOTE_SCHEME.HTTP = 'http' 324 REMOTE_SCHEME.HTTP = 'http'
330 REMOTE_SCHEME.WS = 'ws' 325 REMOTE_SCHEME.WS = 'ws'
@@ -341,7 +336,6 @@ export {
341 CONFIG, 336 CONFIG,
342 CONSTRAINTS_FIELDS, 337 CONSTRAINTS_FIELDS,
343 EMBED_SIZE, 338 EMBED_SIZE,
344 FRIEND_SCORE,
345 JOB_STATES, 339 JOB_STATES,
346 JOBS_FETCH_LIMIT_PER_CYCLE, 340 JOBS_FETCH_LIMIT_PER_CYCLE,
347 JOBS_FETCHING_INTERVAL, 341 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 {
6 isVideoAbuseReasonValid, 6 isVideoAbuseReasonValid,
7 isVideoCategoryValid, 7 isVideoCategoryValid,
8 isVideoDescriptionValid, 8 isVideoDescriptionValid,
9 isVideoDurationValid,
10 isVideoExist, 9 isVideoExist,
11 isVideoFile, 10 isVideoFile,
12 isVideoLanguageValid, 11 isVideoLanguageValid,
@@ -82,14 +81,6 @@ const videosAddValidator = [
82 return 81 return
83 } 82 }
84 83
85 if (!isVideoDurationValid('' + duration)) {
86 return res.status(400)
87 .json({
88 error: 'Duration of the video file is too big (max: ' + CONSTRAINTS_FIELDS.VIDEOS.DURATION.max + 's).'
89 })
90 .end()
91 }
92
93 videoFile['duration'] = duration 84 videoFile['duration'] = duration
94 85
95 return next() 86 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 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { isHostValid, logger } from '../../helpers' 2import { isHostValid, logger } from '../../helpers'
3import { FRIEND_SCORE, SERVERS_SCORE } from '../../initializers' 3import { SERVERS_SCORE } from '../../initializers'
4import { addMethodsToModel } from '../utils' 4import { addMethodsToModel } from '../utils'
5import { ServerAttributes, ServerInstance, ServerMethods } from './server-interface' 5import { ServerAttributes, ServerInstance, ServerMethods } from './server-interface'
6 6
@@ -22,11 +22,11 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
22 }, 22 },
23 score: { 23 score: {
24 type: DataTypes.INTEGER, 24 type: DataTypes.INTEGER,
25 defaultValue: FRIEND_SCORE.BASE, 25 defaultValue: SERVERS_SCORE.BASE,
26 allowNull: false, 26 allowNull: false,
27 validate: { 27 validate: {
28 isInt: true, 28 isInt: true,
29 max: FRIEND_SCORE.MAX 29 max: SERVERS_SCORE.MAX
30 } 30 }
31 } 31 }
32 }, 32 },
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 () {
333 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 333 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
334 }) 334 })
335 335
336 it('Should fail with a too big duration', async function () {
337 const fields = getCompleteVideoUploadAttributes()
338 const attaches = {
339 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm')
340 }
341 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
342 })
343
344 it('Should succeed with the correct parameters', async function () { 336 it('Should succeed with the correct parameters', async function () {
345 this.timeout(10000) 337 this.timeout(10000)
346 338