]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Feature/description support fields length 1000 (#1267)
authorBRAINS YUM <43896676+McFlat@users.noreply.github.com>
Fri, 19 Oct 2018 06:54:01 +0000 (01:54 -0500)
committerChocobozzz <me@florianbigard.com>
Fri, 19 Oct 2018 06:54:01 +0000 (08:54 +0200)
* fix migrations to not use config constant values as it can introduce bugs later when they change; (fixes #1259)
remove constant fields imports from migrations

* add migrations to update description and support fields to 1000 (fixes #1258)

* fix client/server account and video_channel description/support fields to be max len 1000 (fixes #1258);
fix test Should fail with a too long description;
fix test Should fail with a long description;
fix test Should fail with a long description;
Remove USER.SUPPORT from constants since that field no longer exists;
null not false, in migrations/0280-description-support.ts;
video support field 1000, oops;

* rename migration 0280-description-support.ts -> 0285-description-support.ts;
update video support maxlength text

15 files changed:
client/src/app/shared/forms/form-validators/user-validators.service.ts
client/src/app/shared/forms/form-validators/video-channel-validators.service.ts
client/src/app/shared/forms/form-validators/video-validators.service.ts
server/initializers/constants.ts
server/initializers/migrations/0120-video-null.ts
server/initializers/migrations/0195-support.ts
server/initializers/migrations/0245-user-blocked.ts
server/initializers/migrations/0250-video-abuse-state.ts
server/initializers/migrations/0255-video-blacklist-reason.ts
server/initializers/migrations/0260-upload-quota-daily.ts
server/initializers/migrations/0285-description-support.ts [new file with mode: 0644]
server/tests/api/check-params/users.ts
server/tests/api/check-params/video-channels.ts
server/tests/api/check-params/video-imports.ts
server/tests/api/check-params/videos.ts

index 1fd1cdf68ed3220510f8c1b3a2014e0667cbb4bf..d14fa47779b9460d137756c7c0bda4c84e8569d0 100644 (file)
@@ -101,11 +101,11 @@ export class UserValidatorsService {
     this.USER_DESCRIPTION = {
       VALIDATORS: [
         Validators.minLength(3),
-        Validators.maxLength(250)
+        Validators.maxLength(1000)
       ],
       MESSAGES: {
         'minlength': this.i18n('Description must be at least 3 characters long.'),
-        'maxlength': this.i18n('Description cannot be more than 250 characters long.')
+        'maxlength': this.i18n('Description cannot be more than 1000 characters long.')
       }
     }
 
index 1ce3a0dcaceab81086a22022474a8c058afd1396..f62ff65f776b49cbaa4ba33b04dc6434d9d0ed66 100644 (file)
@@ -42,22 +42,22 @@ export class VideoChannelValidatorsService {
     this.VIDEO_CHANNEL_DESCRIPTION = {
       VALIDATORS: [
         Validators.minLength(3),
-        Validators.maxLength(500)
+        Validators.maxLength(1000)
       ],
       MESSAGES: {
         'minlength': i18n('Description must be at least 3 characters long.'),
-        'maxlength': i18n('Description cannot be more than 500 characters long.')
+        'maxlength': i18n('Description cannot be more than 1000 characters long.')
       }
     }
 
     this.VIDEO_CHANNEL_SUPPORT = {
       VALIDATORS: [
         Validators.minLength(3),
-        Validators.maxLength(500)
+        Validators.maxLength(1000)
       ],
       MESSAGES: {
         'minlength': i18n('Support text must be at least 3 characters long.'),
-        'maxlength': i18n('Support text cannot be more than 500 characters long.')
+        'maxlength': i18n('Support text cannot be more than 1000 characters long.')
       }
     }
   }
index 396be6f3b55d5f9d9cc5f75ba6868da2f450afa7..81ed0666f11f41693c741ee80a3d6e5b3be0fc0a 100644 (file)
@@ -79,10 +79,10 @@ export class VideoValidatorsService {
     }
 
     this.VIDEO_SUPPORT = {
-      VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ],
+      VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
       MESSAGES: {
         'minlength': this.i18n('Video support must be at least 3 characters long.'),
-        'maxlength': this.i18n('Video support cannot be more than 500 characters long.')
+        'maxlength': this.i18n('Video support cannot be more than 1000 characters long.')
       }
     }
 
index 03158e356a02ce7b7f318eac86f37df4b36cfb99..e8843a3ab1a8e952938c68da6e67133b76be97c6 100644 (file)
@@ -16,7 +16,7 @@ let config: IConfig = require('config')
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 280
+const LAST_MIGRATION_VERSION = 285
 
 // ---------------------------------------------------------------------------
 
@@ -295,7 +295,7 @@ const CONFIG = {
 const CONSTRAINTS_FIELDS = {
   USERS: {
     NAME: { min: 3, max: 120 }, // Length
-    DESCRIPTION: { min: 3, max: 250 }, // Length
+    DESCRIPTION: { min: 3, max: 1000 }, // Length
     USERNAME: { min: 3, max: 20 }, // Length
     PASSWORD: { min: 6, max: 255 }, // Length
     VIDEO_QUOTA: { min: -1 },
@@ -311,8 +311,8 @@ const CONSTRAINTS_FIELDS = {
   },
   VIDEO_CHANNELS: {
     NAME: { min: 3, max: 120 }, // Length
-    DESCRIPTION: { min: 3, max: 500 }, // Length
-    SUPPORT: { min: 3, max: 500 }, // Length
+    DESCRIPTION: { min: 3, max: 1000 }, // Length
+    SUPPORT: { min: 3, max: 1000 }, // Length
     URL: { min: 3, max: 2000 } // Length
   },
   VIDEO_CAPTIONS: {
@@ -341,7 +341,7 @@ const CONSTRAINTS_FIELDS = {
     LANGUAGE: { min: 1, max: 10 }, // Length
     TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
     DESCRIPTION: { min: 3, max: 10000 }, // Length
-    SUPPORT: { min: 3, max: 500 }, // Length
+    SUPPORT: { min: 3, max: 1000 }, // Length
     IMAGE: {
       EXTNAME: [ '.jpg', '.jpeg' ],
       FILE_SIZE: {
index 63f3984ddaa2a124317cde3f94f20c7d43800948..6d253f04f7c177f0f3e5937f37caa538934020a3 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../constants'
 
 async function up (utils: {
   transaction: Sequelize.Transaction,
@@ -28,7 +27,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max),
+      type: Sequelize.STRING(10000),
       allowNull: true,
       defaultValue: null
     }
index 8722a5f227e785b9f9e3e20b859c027c64ebe72c..3b9eabe79376a9408d1c429a341a05404c3d56c8 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../index'
 
 async function up (utils: {
   transaction: Sequelize.Transaction,
@@ -8,7 +7,7 @@ async function up (utils: {
 }): Promise<void> {
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max),
+      type: Sequelize.STRING(500),
       allowNull: true,
       defaultValue: null
     }
@@ -17,7 +16,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max),
+      type: Sequelize.STRING(500),
       allowNull: true,
       defaultValue: null
     }
@@ -26,7 +25,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max),
+      type: Sequelize.STRING(250),
       allowNull: true,
       defaultValue: null
     }
@@ -35,7 +34,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max),
+      type: Sequelize.STRING(10000),
       allowNull: true,
       defaultValue: null
     }
index 5a04ecd2b2bcccb0b0e6bf36453ebd81770b4685..19c7d5b9c57fa9c4ffa57da8ae9525842684d942 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../constants'
 
 async function up (utils: {
   transaction: Sequelize.Transaction
@@ -31,7 +30,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON.max),
+      type: Sequelize.STRING(250),
       allowNull: true,
       defaultValue: null
     }
index acb668ae14f3a78254b3cb0539a22f0a44b77484..50de25182499bce398ab1b7bde221ec62a3a153d 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../constants'
 import { VideoAbuseState } from '../../../shared/models/videos'
 
 async function up (utils: {
@@ -32,7 +31,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_ABUSES.MODERATION_COMMENT.max),
+      type: Sequelize.STRING(300),
       allowNull: true,
       defaultValue: null
     }
index a380e620ed0ae77c50ca515b32a69885b2aadfd7..69d6efb9ea4d4b2cf19c460b9a9fde1f77e0730b 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../constants'
 import { VideoAbuseState } from '../../../shared/models/videos'
 
 async function up (utils: {
@@ -10,7 +9,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max),
+      type: Sequelize.STRING(300),
       allowNull: true,
       defaultValue: null
     }
index d25154ba69a2df55ee65475c6513510739239c8f..cbbe391ef923303761513c97598ba548e4dd00ad 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../constants'
 
 async function up (utils: {
   transaction: Sequelize.Transaction
diff --git a/server/initializers/migrations/0285-description-support.ts b/server/initializers/migrations/0285-description-support.ts
new file mode 100644 (file)
index 0000000..85ef4ef
--- /dev/null
@@ -0,0 +1,53 @@
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+  transaction: Sequelize.Transaction,
+  queryInterface: Sequelize.QueryInterface,
+  sequelize: Sequelize.Sequelize,
+  db: any
+}): Promise<void> {
+  {
+    const data = {
+      type: Sequelize.STRING(1000),
+      allowNull: true,
+      defaultValue: null
+    }
+    await utils.queryInterface.changeColumn('video', 'support', data)
+  }
+
+  {
+    const data = {
+      type: Sequelize.STRING(1000),
+      allowNull: true,
+      defaultValue: null
+    }
+    await utils.queryInterface.changeColumn('videoChannel', 'support', data)
+  }
+
+  {
+    const data = {
+      type: Sequelize.STRING(1000),
+      allowNull: true,
+      defaultValue: null
+    }
+    await utils.queryInterface.changeColumn('videoChannel', 'description', data)
+  }
+
+  {
+    const data = {
+      type: Sequelize.STRING(1000),
+      allowNull: true,
+      defaultValue: null
+    }
+    await utils.queryInterface.changeColumn('account', 'description', data)
+  }
+}
+
+function down (options) {
+  throw new Error('Not implemented.')
+}
+
+export {
+  up,
+  down
+}
index cbfa0c137cd879b2cdd2ce08f8a45294d48f5b2c..ec46609a4c2f5f0ff0e84373cb8a6dc4463625b3 100644 (file)
@@ -315,7 +315,7 @@ describe('Test users API validators', function () {
 
     it('Should fail with a too long description', async function () {
       const fields = {
-        description: 'super'.repeat(60)
+        description: 'super'.repeat(201)
       }
 
       await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
index 3a7942945a107c4571f0642773c6189a285e431b..e5696224dacdcfccfe7f099e29cce2f938145d8c 100644 (file)
@@ -118,12 +118,12 @@ describe('Test video channels API validator', function () {
     })
 
     it('Should fail with a long description', async function () {
-      const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(201) })
       await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
     })
 
     it('Should fail with a long support text', async function () {
-      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
       await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
     })
 
@@ -185,12 +185,12 @@ describe('Test video channels API validator', function () {
     })
 
     it('Should fail with a long description', async function () {
-      const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(201) })
       await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
     })
 
     it('Should fail with a long support text', async function () {
-      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
       await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
     })
 
index 44645b0e2531a9e9b0c5e6f0b966b38c81644290..b51f3d2cd6a8d3b45b98402671154599637fb3d3 100644 (file)
@@ -140,7 +140,7 @@ describe('Test video imports API validator', function () {
     })
 
     it('Should fail with a long support text', async function () {
-      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
 
       await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
     })
index 904d2287090b12dc3859c4779541d99b1d3ce80a..699f135c79410c1c010be94c0f4aaed83da0375b 100644 (file)
@@ -233,7 +233,7 @@ describe('Test videos API validator', function () {
     })
 
     it('Should fail with a long support text', async function () {
-      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
       const attaches = baseCorrectAttaches
 
       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -482,7 +482,7 @@ describe('Test videos API validator', function () {
     })
 
     it('Should fail with a long support text', async function () {
-      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) })
+      const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
 
       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
     })