diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 11:08:25 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | efc32059d980c51793e8e9ac0fb6a885a8026f94 (patch) | |
tree | c272e63fd57a9625b53dc26ceb1b46aee35d21d3 /server/helpers/custom-validators/activitypub | |
parent | d846501818c2d29e66e6fd141789cb04fd55a437 (diff) | |
download | PeerTube-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/activitypub')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 15 |
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 | ||
40 | function isVideoTorrentObjectValid (video: any) { | 40 | function 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 | ||
58 | function isVideoFlagValid (activity: any) { | 59 | function 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 | ||
139 | function setValidRemoteVideoUrls (video: any) { | 140 | function 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 | } |