diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-14 10:57:56 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | e34c85e527100c0b5c44567bd951e95be41b8d7e (patch) | |
tree | 39697c5a4dda2c2e07142a8522538db783fce2fd /server/models/video | |
parent | 1e1265b36c09df1465aa2b4866815c957b6a532e (diff) | |
download | PeerTube-e34c85e527100c0b5c44567bd951e95be41b8d7e.tar.gz PeerTube-e34c85e527100c0b5c44567bd951e95be41b8d7e.tar.zst PeerTube-e34c85e527100c0b5c44567bd951e95be41b8d7e.zip |
Fix issues on server start
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-channel.ts | 9 | ||||
-rw-r--r-- | server/models/video/video.ts | 8 |
2 files changed, 13 insertions, 4 deletions
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 { | |||
10 | VideoChannelMethods | 10 | VideoChannelMethods |
11 | } from './video-channel-interface' | 11 | } from './video-channel-interface' |
12 | import { sendDeleteVideoChannel } from '../../lib/activitypub/send-request' | 12 | import { sendDeleteVideoChannel } from '../../lib/activitypub/send-request' |
13 | import { isVideoChannelUrlValid } from '../../helpers/custom-validators/video-channels' | ||
14 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | ||
13 | 15 | ||
14 | let VideoChannel: Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> | 16 | let VideoChannel: Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> |
15 | let toFormattedJSON: VideoChannelMethods.ToFormattedJSON | 17 | let toFormattedJSON: VideoChannelMethods.ToFormattedJSON |
@@ -65,10 +67,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
65 | defaultValue: false | 67 | defaultValue: false |
66 | }, | 68 | }, |
67 | url: { | 69 | url: { |
68 | type: DataTypes.STRING, | 70 | type: DataTypes.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.URL.max), |
69 | allowNull: false, | 71 | allowNull: false, |
70 | validate: { | 72 | validate: { |
71 | isUrl: true | 73 | urlValid: value => { |
74 | const res = isVideoChannelUrlValid(value) | ||
75 | if (res === false) throw new Error('Video channel URL is not valid.') | ||
76 | } | ||
72 | } | 77 | } |
73 | } | 78 | } |
74 | }, | 79 | }, |
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' | |||
46 | import { VideoFileInstance, VideoFileModel } from './video-file-interface' | 46 | import { VideoFileInstance, VideoFileModel } from './video-file-interface' |
47 | import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' | 47 | import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' |
48 | import { sendDeleteVideo } from '../../lib/activitypub/send-request' | 48 | import { sendDeleteVideo } from '../../lib/activitypub/send-request' |
49 | import { isVideoUrlValid } from '../../helpers/custom-validators/videos' | ||
49 | 50 | ||
50 | const Buffer = safeBuffer.Buffer | 51 | const Buffer = safeBuffer.Buffer |
51 | 52 | ||
@@ -220,10 +221,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
220 | defaultValue: false | 221 | defaultValue: false |
221 | }, | 222 | }, |
222 | url: { | 223 | url: { |
223 | type: DataTypes.STRING, | 224 | type: DataTypes.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max), |
224 | allowNull: false, | 225 | allowNull: false, |
225 | validate: { | 226 | validate: { |
226 | isUrl: true | 227 | urlValid: value => { |
228 | const res = isVideoUrlValid(value) | ||
229 | if (res === false) throw new Error('Video URL is not valid.') | ||
230 | } | ||
227 | } | 231 | } |
228 | } | 232 | } |
229 | }, | 233 | }, |