diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-15 16:28:35 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 8e10cf1a5a438a00e5f7e0691cb830769867cffc (patch) | |
tree | 23c0aeb43d7fb05b2d280c37b4334c2f320b647e /server/helpers/custom-validators/activitypub | |
parent | 8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391 (diff) | |
download | PeerTube-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.ts | 30 |
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 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | 2 | import { ACTIVITY_PUB } from '../../../initializers' | |
3 | import { | 3 | import { exists, isDateValid, isUUIDValid } from '../misc' |
4 | ACTIVITY_PUB | 4 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' |
5 | } from '../../../initializers' | ||
6 | import { isDateValid, isUUIDValid } from '../misc' | ||
7 | import { | 5 | import { |
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' |
16 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' | 14 | import { isBaseActivityValid } from './misc' |
17 | import { isActivityPubUrlValid, isBaseActivityValid } from './misc' | ||
18 | 15 | ||
19 | function isVideoTorrentAddActivityValid (activity: any) { | 16 | function 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 | ||
30 | function 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 | |||
33 | function isVideoTorrentObjectValid (video: any) { | 39 | function 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) && |