diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/account/account.ts | 19 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 23 |
3 files changed, 23 insertions, 23 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index fff3ce087..c721656cb 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -2,17 +2,12 @@ import * as Sequelize from 'sequelize' | |||
2 | import { | 2 | import { |
3 | activityPubContextify, | 3 | activityPubContextify, |
4 | isAccountFollowersCountValid, | 4 | isAccountFollowersCountValid, |
5 | isAccountFollowersValid, | ||
6 | isAccountFollowingCountValid, | 5 | isAccountFollowingCountValid, |
7 | isAccountFollowingValid, | ||
8 | isAccountInboxValid, | ||
9 | isAccountOutboxValid, | ||
10 | isAccountPrivateKeyValid, | 6 | isAccountPrivateKeyValid, |
11 | isAccountPublicKeyValid, | 7 | isAccountPublicKeyValid, |
12 | isAccountSharedInboxValid, | ||
13 | isAccountUrlValid, | ||
14 | isUserUsernameValid | 8 | isUserUsernameValid |
15 | } from '../../helpers' | 9 | } from '../../helpers' |
10 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | ||
16 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' | 11 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' |
17 | import { sendDeleteAccount } from '../../lib/activitypub/send/send-delete' | 12 | import { sendDeleteAccount } from '../../lib/activitypub/send/send-delete' |
18 | 13 | ||
@@ -61,7 +56,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
61 | allowNull: false, | 56 | allowNull: false, |
62 | validate: { | 57 | validate: { |
63 | urlValid: value => { | 58 | urlValid: value => { |
64 | const res = isAccountUrlValid(value) | 59 | const res = isActivityPubUrlValid(value) |
65 | if (res === false) throw new Error('URL is not valid.') | 60 | if (res === false) throw new Error('URL is not valid.') |
66 | } | 61 | } |
67 | } | 62 | } |
@@ -111,7 +106,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
111 | allowNull: false, | 106 | allowNull: false, |
112 | validate: { | 107 | validate: { |
113 | inboxUrlValid: value => { | 108 | inboxUrlValid: value => { |
114 | const res = isAccountInboxValid(value) | 109 | const res = isActivityPubUrlValid(value) |
115 | if (res === false) throw new Error('Inbox URL is not valid.') | 110 | if (res === false) throw new Error('Inbox URL is not valid.') |
116 | } | 111 | } |
117 | } | 112 | } |
@@ -121,7 +116,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
121 | allowNull: false, | 116 | allowNull: false, |
122 | validate: { | 117 | validate: { |
123 | outboxUrlValid: value => { | 118 | outboxUrlValid: value => { |
124 | const res = isAccountOutboxValid(value) | 119 | const res = isActivityPubUrlValid(value) |
125 | if (res === false) throw new Error('Outbox URL is not valid.') | 120 | if (res === false) throw new Error('Outbox URL is not valid.') |
126 | } | 121 | } |
127 | } | 122 | } |
@@ -131,7 +126,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
131 | allowNull: false, | 126 | allowNull: false, |
132 | validate: { | 127 | validate: { |
133 | sharedInboxUrlValid: value => { | 128 | sharedInboxUrlValid: value => { |
134 | const res = isAccountSharedInboxValid(value) | 129 | const res = isActivityPubUrlValid(value) |
135 | if (res === false) throw new Error('Shared inbox URL is not valid.') | 130 | if (res === false) throw new Error('Shared inbox URL is not valid.') |
136 | } | 131 | } |
137 | } | 132 | } |
@@ -141,7 +136,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
141 | allowNull: false, | 136 | allowNull: false, |
142 | validate: { | 137 | validate: { |
143 | followersUrlValid: value => { | 138 | followersUrlValid: value => { |
144 | const res = isAccountFollowersValid(value) | 139 | const res = isActivityPubUrlValid(value) |
145 | if (res === false) throw new Error('Followers URL is not valid.') | 140 | if (res === false) throw new Error('Followers URL is not valid.') |
146 | } | 141 | } |
147 | } | 142 | } |
@@ -151,7 +146,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
151 | allowNull: false, | 146 | allowNull: false, |
152 | validate: { | 147 | validate: { |
153 | followingUrlValid: value => { | 148 | followingUrlValid: value => { |
154 | const res = isAccountFollowingValid(value) | 149 | const res = isActivityPubUrlValid(value) |
155 | if (res === false) throw new Error('Following URL is not valid.') | 150 | if (res === false) throw new Error('Following URL is not valid.') |
156 | } | 151 | } |
157 | } | 152 | } |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index e11268b2c..54f12dce3 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers' | 2 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers' |
3 | import { isVideoChannelUrlValid } from '../../helpers/custom-validators/video-channels' | ||
4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 3 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
5 | import { sendDeleteVideoChannel } from '../../lib/activitypub/send/send-delete' | 4 | import { sendDeleteVideoChannel } from '../../lib/activitypub/send/send-delete' |
6 | 5 | ||
@@ -8,6 +7,7 @@ import { addMethodsToModel, getSort } from '../utils' | |||
8 | import { VideoChannelAttributes, VideoChannelInstance, VideoChannelMethods } from './video-channel-interface' | 7 | import { VideoChannelAttributes, VideoChannelInstance, VideoChannelMethods } from './video-channel-interface' |
9 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' | 8 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' |
10 | import { activityPubCollection } from '../../helpers/activitypub' | 9 | import { activityPubCollection } from '../../helpers/activitypub' |
10 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | ||
11 | 11 | ||
12 | let VideoChannel: Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> | 12 | let VideoChannel: Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> |
13 | let toFormattedJSON: VideoChannelMethods.ToFormattedJSON | 13 | let toFormattedJSON: VideoChannelMethods.ToFormattedJSON |
@@ -66,7 +66,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
66 | allowNull: false, | 66 | allowNull: false, |
67 | validate: { | 67 | validate: { |
68 | urlValid: value => { | 68 | urlValid: value => { |
69 | const res = isVideoChannelUrlValid(value) | 69 | const res = isActivityPubUrlValid(value) |
70 | if (res === false) throw new Error('Video channel URL is not valid.') | 70 | if (res === false) throw new Error('Video channel URL is not valid.') |
71 | } | 71 | } |
72 | } | 72 | } |
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 | } |