From: Chocobozzz Date: Wed, 9 May 2018 11:32:44 +0000 (+0200) Subject: Fix video channel description/support max length X-Git-Tag: v1.0.0-beta.5~57 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a10fc78bb0e00e98c8f59edc16cd323b9c8b0615;p=oweals%2Fpeertube.git Fix video channel description/support max length --- diff --git a/client/src/app/shared/forms/form-validators/video-channel.ts b/client/src/app/shared/forms/form-validators/video-channel.ts index 6233d17f7..2185cdaa9 100644 --- a/client/src/app/shared/forms/form-validators/video-channel.ts +++ b/client/src/app/shared/forms/form-validators/video-channel.ts @@ -15,20 +15,20 @@ export const VIDEO_CHANNEL_DISPLAY_NAME = { export const VIDEO_CHANNEL_DESCRIPTION = { VALIDATORS: [ Validators.minLength(3), - Validators.maxLength(250) + Validators.maxLength(500) ], MESSAGES: { 'minlength': 'Description must be at least 3 characters long.', - 'maxlength': 'Description cannot be more than 250 characters long.' + 'maxlength': 'Description cannot be more than 500 characters long.' } } export const VIDEO_CHANNEL_SUPPORT = { VALIDATORS: [ Validators.minLength(3), - Validators.maxLength(300) + Validators.maxLength(500) ], MESSAGES: { 'minlength': 'Support text must be at least 3 characters long.', - 'maxlength': 'Support text cannot be more than 300 characters long.' + 'maxlength': 'Support text cannot be more than 500 characters long.' } } diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index 9ecbbbd60..a986243df 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts @@ -60,9 +60,9 @@ export const VIDEO_TAGS = { } export const VIDEO_SUPPORT = { - VALIDATORS: [ Validators.minLength(3), Validators.maxLength(300) ], + VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ], MESSAGES: { 'minlength': 'Video support must be at least 3 characters long.', - 'maxlength': 'Video support cannot be more than 300 characters long.' + 'maxlength': 'Video support cannot be more than 500 characters long.' } } diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 6556aa168..c52c27c78 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -13,7 +13,7 @@ let config: IConfig = require('config') // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 210 +const LAST_MIGRATION_VERSION = 215 // --------------------------------------------------------------------------- @@ -192,8 +192,8 @@ const CONSTRAINTS_FIELDS = { }, VIDEO_CHANNELS: { NAME: { min: 3, max: 120 }, // Length - DESCRIPTION: { min: 3, max: 250 }, // Length - SUPPORT: { min: 3, max: 300 }, // Length + DESCRIPTION: { min: 3, max: 500 }, // Length + SUPPORT: { min: 3, max: 500 }, // Length URL: { min: 3, max: 2000 } // Length }, VIDEOS: { @@ -201,7 +201,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: 300 }, // Length + SUPPORT: { min: 3, max: 500 }, // Length IMAGE: { EXTNAME: [ '.jpg', '.jpeg' ], FILE_SIZE: { diff --git a/server/initializers/migrations/0215-video-support-length.ts b/server/initializers/migrations/0215-video-support-length.ts new file mode 100644 index 000000000..994eda60d --- /dev/null +++ b/server/initializers/migrations/0215-video-support-length.ts @@ -0,0 +1,44 @@ +import * as Sequelize from 'sequelize' +import { CONSTRAINTS_FIELDS } from '../index' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize +}): Promise { + { + const data = { + type: Sequelize.STRING(500), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('video', 'support', data) + } + + { + const data = { + type: Sequelize.STRING(500), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('videoChannel', 'support', data) + } + + { + const data = { + type: Sequelize.STRING(500), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('videoChannel', 'description', data) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 4a50af265..8498143fe 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -1,6 +1,6 @@ import { AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table, - UpdatedAt, Default + UpdatedAt, Default, DataType } from 'sequelize-typescript' import { ActivityPubActor } from '../../../shared/models/activitypub' import { VideoChannel } from '../../../shared/models/videos' @@ -14,6 +14,7 @@ import { AccountModel } from '../account/account' import { ActorModel } from '../activitypub/actor' import { getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' +import { CONSTRAINTS_FIELDS } from '../../initializers' enum ScopeNames { WITH_ACCOUNT = 'WITH_ACCOUNT', @@ -73,13 +74,13 @@ export class VideoChannelModel extends Model { @AllowNull(true) @Default(null) @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description')) - @Column + @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max)) description: string @AllowNull(true) @Default(null) @Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support')) - @Column + @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max)) support: string @CreatedAt