aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/activitypub
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-15 16:28:35 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit8e10cf1a5a438a00e5f7e0691cb830769867cffc (patch)
tree23c0aeb43d7fb05b2d280c37b4334c2f320b647e /server/helpers/custom-validators/activitypub
parent8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391 (diff)
downloadPeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.tar.gz
PeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.tar.zst
PeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.zip
Fix video upload and videos list
Diffstat (limited to 'server/helpers/custom-validators/activitypub')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts30
1 files changed, 18 insertions, 12 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index c9ecf1f3d..a46757397 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -1,20 +1,17 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2 2import { ACTIVITY_PUB } from '../../../initializers'
3import { 3import { exists, isDateValid, isUUIDValid } from '../misc'
4 ACTIVITY_PUB 4import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels'
5} from '../../../initializers'
6import { isDateValid, isUUIDValid } from '../misc'
7import { 5import {
8 isVideoViewsValid,
9 isVideoNSFWValid,
10 isVideoTruncatedDescriptionValid,
11 isVideoDurationValid, 6 isVideoDurationValid,
12 isVideoNameValid, 7 isVideoNameValid,
8 isVideoNSFWValid,
13 isVideoTagValid, 9 isVideoTagValid,
14 isVideoUrlValid 10 isVideoTruncatedDescriptionValid,
11 isVideoUrlValid,
12 isVideoViewsValid
15} from '../videos' 13} from '../videos'
16import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' 14import { isBaseActivityValid } from './misc'
17import { isActivityPubUrlValid, isBaseActivityValid } from './misc'
18 15
19function isVideoTorrentAddActivityValid (activity: any) { 16function isVideoTorrentAddActivityValid (activity: any) {
20 return isBaseActivityValid(activity, 'Add') && 17 return isBaseActivityValid(activity, 'Add') &&
@@ -30,10 +27,19 @@ function isVideoTorrentDeleteActivityValid (activity: any) {
30 return isBaseActivityValid(activity, 'Delete') 27 return isBaseActivityValid(activity, 'Delete')
31} 28}
32 29
30function isActivityPubVideoDurationValid (value: string) {
31 // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
32 return exists(value) &&
33 typeof value === 'string' &&
34 value.startsWith('PT') &&
35 value.endsWith('S') &&
36 isVideoDurationValid(value.replace(/[^0-9]+/, ''))
37}
38
33function isVideoTorrentObjectValid (video: any) { 39function isVideoTorrentObjectValid (video: any) {
34 return video.type === 'Video' && 40 return video.type === 'Video' &&
35 isVideoNameValid(video.name) && 41 isVideoNameValid(video.name) &&
36 isVideoDurationValid(video.duration) && 42 isActivityPubVideoDurationValid(video.duration) &&
37 isUUIDValid(video.uuid) && 43 isUUIDValid(video.uuid) &&
38 setValidRemoteTags(video) && 44 setValidRemoteTags(video) &&
39 isRemoteIdentifierValid(video.category) && 45 isRemoteIdentifierValid(video.category) &&