Fix video channel description/support max length

pull/559/head
Chocobozzz 2018-05-09 13:32:44 +02:00
parent 360329cc02
commit a10fc78bb0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 58 additions and 13 deletions

View File

@ -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.'
}
}

View File

@ -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.'
}
}

View File

@ -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: {

View File

@ -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<void> {
{
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
}

View File

@ -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<VideoChannelModel> {
@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