aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-16 11:08:25 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commitefc32059d980c51793e8e9ac0fb6a885a8026f94 (patch)
treec272e63fd57a9625b53dc26ceb1b46aee35d21d3 /server/helpers/custom-validators
parentd846501818c2d29e66e6fd141789cb04fd55a437 (diff)
downloadPeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.tar.gz
PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.tar.zst
PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.zip
Send server announce when users upload a video
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index 9ddacd601..89c49b0df 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -34,7 +34,7 @@ function isActivityPubVideoDurationValid (value: string) {
34 typeof value === 'string' && 34 typeof value === 'string' &&
35 value.startsWith('PT') && 35 value.startsWith('PT') &&
36 value.endsWith('S') && 36 value.endsWith('S') &&
37 isVideoDurationValid(value.replace(/[^0-9]+/, '')) 37 isVideoDurationValid(value.replace(/[^0-9]+/g, ''))
38} 38}
39 39
40function isVideoTorrentObjectValid (video: any) { 40function isVideoTorrentObjectValid (video: any) {
@@ -46,13 +46,14 @@ function isVideoTorrentObjectValid (video: any) {
46 isRemoteIdentifierValid(video.category) && 46 isRemoteIdentifierValid(video.category) &&
47 isRemoteIdentifierValid(video.licence) && 47 isRemoteIdentifierValid(video.licence) &&
48 isRemoteIdentifierValid(video.language) && 48 isRemoteIdentifierValid(video.language) &&
49 isVideoViewsValid(video.video) && 49 isVideoViewsValid(video.views) &&
50 isVideoNSFWValid(video.nsfw) && 50 isVideoNSFWValid(video.nsfw) &&
51 isDateValid(video.published) && 51 isDateValid(video.published) &&
52 isDateValid(video.updated) && 52 isDateValid(video.updated) &&
53 isRemoteVideoContentValid(video.mediaType, video.content) && 53 isRemoteVideoContentValid(video.mediaType, video.content) &&
54 isRemoteVideoIconValid(video.icon) && 54 isRemoteVideoIconValid(video.icon) &&
55 setValidRemoteVideoUrls(video.url) 55 setValidRemoteVideoUrls(video) &&
56 video.url.length !== 0
56} 57}
57 58
58function isVideoFlagValid (activity: any) { 59function isVideoFlagValid (activity: any) {
@@ -132,8 +133,8 @@ function isRemoteVideoIconValid (icon: any) {
132 return icon.type === 'Image' && 133 return icon.type === 'Image' &&
133 isVideoUrlValid(icon.url) && 134 isVideoUrlValid(icon.url) &&
134 icon.mediaType === 'image/jpeg' && 135 icon.mediaType === 'image/jpeg' &&
135 validator.isInt(icon.width, { min: 0 }) && 136 validator.isInt(icon.width + '', { min: 0 }) &&
136 validator.isInt(icon.height, { min: 0 }) 137 validator.isInt(icon.height + '', { min: 0 })
137} 138}
138 139
139function setValidRemoteVideoUrls (video: any) { 140function setValidRemoteVideoUrls (video: any) {
@@ -149,6 +150,6 @@ function isRemoteVideoUrlValid (url: any) {
149 return url.type === 'Link' && 150 return url.type === 'Link' &&
150 ACTIVITY_PUB.VIDEO_URL_MIME_TYPES.indexOf(url.mimeType) !== -1 && 151 ACTIVITY_PUB.VIDEO_URL_MIME_TYPES.indexOf(url.mimeType) !== -1 &&
151 isVideoUrlValid(url.url) && 152 isVideoUrlValid(url.url) &&
152 validator.isInt(url.width, { min: 0 }) && 153 validator.isInt(url.width + '', { min: 0 }) &&
153 validator.isInt(url.size, { min: 0 }) 154 validator.isInt(url.size + '', { min: 0 })
154} 155}