diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 17:30:46 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:43:01 +0100 |
commit | a2431b7dcbc72c05101dcdbe631ff84a823aeb51 (patch) | |
tree | 09278a822905622a70ff976a75e09d99bc45639a /server/models/video/video.ts | |
parent | fcaf1e0aa84213a1b1f1b1a44a3276eae35ebe70 (diff) | |
download | PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.gz PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.zst PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.zip |
Refractor validators
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 4956b57ee..3f416d04c 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -7,7 +7,18 @@ import * as Sequelize from 'sequelize' | |||
7 | import { VideoPrivacy, VideoResolution } from '../../../shared' | 7 | import { VideoPrivacy, VideoResolution } from '../../../shared' |
8 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' | 8 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' |
9 | import { activityPubCollection } from '../../helpers/activitypub' | 9 | import { activityPubCollection } from '../../helpers/activitypub' |
10 | import { isVideoCategoryValid, isVideoLanguageValid, isVideoPrivacyValid, isVideoUrlValid } from '../../helpers/custom-validators/videos' | 10 | import { createTorrentPromise, renamePromise, statPromise, unlinkPromise, writeFilePromise } from '../../helpers/core-utils' |
11 | import { isVideoCategoryValid, isVideoLanguageValid, isVideoPrivacyValid } from '../../helpers/custom-validators/videos' | ||
12 | import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' | ||
13 | import { | ||
14 | isActivityPubUrlValid, | ||
15 | isVideoDescriptionValid, | ||
16 | isVideoDurationValid, | ||
17 | isVideoLicenceValid, | ||
18 | isVideoNameValid, | ||
19 | isVideoNSFWValid | ||
20 | } from '../../helpers/index' | ||
21 | import { logger } from '../../helpers/logger' | ||
11 | import { | 22 | import { |
12 | API_VERSION, | 23 | API_VERSION, |
13 | CONFIG, | 24 | CONFIG, |
@@ -21,18 +32,12 @@ import { | |||
21 | VIDEO_LICENCES, | 32 | VIDEO_LICENCES, |
22 | VIDEO_PRIVACIES | 33 | VIDEO_PRIVACIES |
23 | } from '../../initializers/constants' | 34 | } from '../../initializers/constants' |
35 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' | ||
24 | import { sendDeleteVideo } from '../../lib/index' | 36 | import { sendDeleteVideo } from '../../lib/index' |
25 | |||
26 | import { addMethodsToModel, getSort } from '../utils' | 37 | import { addMethodsToModel, getSort } from '../utils' |
27 | |||
28 | import { TagInstance } from './tag-interface' | 38 | import { TagInstance } from './tag-interface' |
29 | import { VideoFileInstance, VideoFileModel } from './video-file-interface' | 39 | import { VideoFileInstance, VideoFileModel } from './video-file-interface' |
30 | import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' | 40 | import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' |
31 | import { isVideoNameValid, isVideoLicenceValid, isVideoNSFWValid, isVideoDescriptionValid, isVideoDurationValid } from '../../helpers/index' | ||
32 | import { logger } from '../../helpers/logger' | ||
33 | import { generateImageFromVideoFile, transcode, getVideoFileHeight } from '../../helpers/ffmpeg-utils' | ||
34 | import { createTorrentPromise, writeFilePromise, unlinkPromise, renamePromise, statPromise } from '../../helpers/core-utils' | ||
35 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' | ||
36 | 41 | ||
37 | let Video: Sequelize.Model<VideoInstance, VideoAttributes> | 42 | let Video: Sequelize.Model<VideoInstance, VideoAttributes> |
38 | let getOriginalFile: VideoMethods.GetOriginalFile | 43 | let getOriginalFile: VideoMethods.GetOriginalFile |
@@ -205,7 +210,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
205 | allowNull: false, | 210 | allowNull: false, |
206 | validate: { | 211 | validate: { |
207 | urlValid: value => { | 212 | urlValid: value => { |
208 | const res = isVideoUrlValid(value) | 213 | const res = isActivityPubUrlValid(value) |
209 | if (res === false) throw new Error('Video URL is not valid.') | 214 | if (res === false) throw new Error('Video URL is not valid.') |
210 | } | 215 | } |
211 | } | 216 | } |