From e34c85e527100c0b5c44567bd951e95be41b8d7e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 Nov 2017 10:57:56 +0100 Subject: Fix issues on server start --- server/models/video/video-channel.ts | 9 +++++++-- server/models/video/video.ts | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 919ec916d..6d70f2aa2 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -10,6 +10,8 @@ import { VideoChannelMethods } from './video-channel-interface' import { sendDeleteVideoChannel } from '../../lib/activitypub/send-request' +import { isVideoChannelUrlValid } from '../../helpers/custom-validators/video-channels' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' let VideoChannel: Sequelize.Model let toFormattedJSON: VideoChannelMethods.ToFormattedJSON @@ -65,10 +67,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da defaultValue: false }, url: { - type: DataTypes.STRING, + type: DataTypes.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.URL.max), allowNull: false, validate: { - isUrl: true + urlValid: value => { + const res = isVideoChannelUrlValid(value) + if (res === false) throw new Error('Video channel URL is not valid.') + } } } }, diff --git a/server/models/video/video.ts b/server/models/video/video.ts index ca71da375..dd73dd7ca 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -46,6 +46,7 @@ import { TagInstance } from './tag-interface' import { VideoFileInstance, VideoFileModel } from './video-file-interface' import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' import { sendDeleteVideo } from '../../lib/activitypub/send-request' +import { isVideoUrlValid } from '../../helpers/custom-validators/videos' const Buffer = safeBuffer.Buffer @@ -220,10 +221,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da defaultValue: false }, url: { - type: DataTypes.STRING, + type: DataTypes.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max), allowNull: false, validate: { - isUrl: true + urlValid: value => { + const res = isVideoUrlValid(value) + if (res === false) throw new Error('Video URL is not valid.') + } } } }, -- cgit v1.2.3