diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 15:22:39 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 20494f122186bb1bfd82f4c598c4744acea27b0c (patch) | |
tree | 097652a31ecf70491b970b6c8e06b22380ee004f /server/helpers/custom-validators/activitypub/videos.ts | |
parent | efc32059d980c51793e8e9ac0fb6a885a8026f94 (diff) | |
download | PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.tar.gz PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.tar.zst PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.zip |
Server shares user videos
Diffstat (limited to 'server/helpers/custom-validators/activitypub/videos.ts')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index 89c49b0df..8486297ad 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -39,6 +39,7 @@ function isActivityPubVideoDurationValid (value: string) { | |||
39 | 39 | ||
40 | function isVideoTorrentObjectValid (video: any) { | 40 | function isVideoTorrentObjectValid (video: any) { |
41 | return video.type === 'Video' && | 41 | return video.type === 'Video' && |
42 | isActivityPubUrlValid(video.id) && | ||
42 | isVideoNameValid(video.name) && | 43 | isVideoNameValid(video.name) && |
43 | isActivityPubVideoDurationValid(video.duration) && | 44 | isActivityPubVideoDurationValid(video.duration) && |
44 | isUUIDValid(video.uuid) && | 45 | isUUIDValid(video.uuid) && |
@@ -62,14 +63,12 @@ function isVideoFlagValid (activity: any) { | |||
62 | isActivityPubUrlValid(activity.object) | 63 | isActivityPubUrlValid(activity.object) |
63 | } | 64 | } |
64 | 65 | ||
65 | function isVideoAnnounceValid (activity: any) { | 66 | function isAnnounceValid (activity: any) { |
66 | return isBaseActivityValid(activity, 'Announce') && | 67 | return isBaseActivityValid(activity, 'Announce') && |
67 | isVideoTorrentObjectValid(activity.object) | 68 | ( |
68 | } | 69 | isVideoChannelCreateActivityValid(activity.object) || |
69 | 70 | isVideoTorrentAddActivityValid(activity.object) | |
70 | function isVideoChannelAnnounceValid (activity: any) { | 71 | ) |
71 | return isBaseActivityValid(activity, 'Announce') && | ||
72 | isVideoChannelObjectValid(activity.object) | ||
73 | } | 72 | } |
74 | 73 | ||
75 | function isVideoChannelCreateActivityValid (activity: any) { | 74 | function isVideoChannelCreateActivityValid (activity: any) { |
@@ -88,8 +87,11 @@ function isVideoChannelDeleteActivityValid (activity: any) { | |||
88 | 87 | ||
89 | function isVideoChannelObjectValid (videoChannel: any) { | 88 | function isVideoChannelObjectValid (videoChannel: any) { |
90 | return videoChannel.type === 'VideoChannel' && | 89 | return videoChannel.type === 'VideoChannel' && |
90 | isActivityPubUrlValid(videoChannel.id) && | ||
91 | isVideoChannelNameValid(videoChannel.name) && | 91 | isVideoChannelNameValid(videoChannel.name) && |
92 | isVideoChannelDescriptionValid(videoChannel.description) && | 92 | isVideoChannelDescriptionValid(videoChannel.content) && |
93 | isDateValid(videoChannel.published) && | ||
94 | isDateValid(videoChannel.updated) && | ||
93 | isUUIDValid(videoChannel.uuid) | 95 | isUUIDValid(videoChannel.uuid) |
94 | } | 96 | } |
95 | 97 | ||
@@ -103,8 +105,8 @@ export { | |||
103 | isVideoChannelDeleteActivityValid, | 105 | isVideoChannelDeleteActivityValid, |
104 | isVideoTorrentDeleteActivityValid, | 106 | isVideoTorrentDeleteActivityValid, |
105 | isVideoFlagValid, | 107 | isVideoFlagValid, |
106 | isVideoAnnounceValid, | 108 | isAnnounceValid, |
107 | isVideoChannelAnnounceValid | 109 | isVideoChannelObjectValid |
108 | } | 110 | } |
109 | 111 | ||
110 | // --------------------------------------------------------------------------- | 112 | // --------------------------------------------------------------------------- |
@@ -148,8 +150,20 @@ function setValidRemoteVideoUrls (video: any) { | |||
148 | 150 | ||
149 | function isRemoteVideoUrlValid (url: any) { | 151 | function isRemoteVideoUrlValid (url: any) { |
150 | return url.type === 'Link' && | 152 | return url.type === 'Link' && |
151 | ACTIVITY_PUB.VIDEO_URL_MIME_TYPES.indexOf(url.mimeType) !== -1 && | 153 | ( |
152 | isVideoUrlValid(url.url) && | 154 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && |
153 | validator.isInt(url.width + '', { min: 0 }) && | 155 | isVideoUrlValid(url.url) && |
154 | validator.isInt(url.size + '', { min: 0 }) | 156 | validator.isInt(url.width + '', { min: 0 }) && |
157 | validator.isInt(url.size + '', { min: 0 }) | ||
158 | ) || | ||
159 | ( | ||
160 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && | ||
161 | isVideoUrlValid(url.url) && | ||
162 | validator.isInt(url.width + '', { min: 0 }) | ||
163 | ) || | ||
164 | ( | ||
165 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && | ||
166 | validator.isLength(url.url, { min: 5 }) && | ||
167 | validator.isInt(url.width + '', { min: 0 }) | ||
168 | ) | ||
155 | } | 169 | } |