aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-17 11:24:36 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit965c4b22d0e4d2f853501e844e6ebbb861bd389d (patch)
tree519574c83ea070968d9561d493bc16ac2e285090 /server/helpers/custom-validators
parent06a05d5f4784a7cbb27aa1188385b5679845dad8 (diff)
downloadPeerTube-965c4b22d0e4d2f853501e844e6ebbb861bd389d.tar.gz
PeerTube-965c4b22d0e4d2f853501e844e6ebbb861bd389d.tar.zst
PeerTube-965c4b22d0e4d2f853501e844e6ebbb861bd389d.zip
Use height instead of width to represent the video resolution
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index 702c09842..0362f43ab 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -148,22 +148,25 @@ function setRemoteVideoTruncatedContent (video: any) {
148} 148}
149 149
150function isRemoteVideoUrlValid (url: any) { 150function isRemoteVideoUrlValid (url: any) {
151 // FIXME: Old bug, we used the width to represent the resolution. Remove it in a few realease (currently beta.11)
152 if (url.width && !url.height) url.height = url.width
153
151 return url.type === 'Link' && 154 return url.type === 'Link' &&
152 ( 155 (
153 ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && 156 ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 &&
154 isActivityPubUrlValid(url.href) && 157 isActivityPubUrlValid(url.href) &&
155 validator.isInt(url.width + '', { min: 0 }) && 158 validator.isInt(url.height + '', { min: 0 }) &&
156 validator.isInt(url.size + '', { min: 0 }) && 159 validator.isInt(url.size + '', { min: 0 }) &&
157 (!url.fps || validator.isInt(url.fps + '', { min: 0 })) 160 (!url.fps || validator.isInt(url.fps + '', { min: 0 }))
158 ) || 161 ) ||
159 ( 162 (
160 ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && 163 ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
161 isActivityPubUrlValid(url.href) && 164 isActivityPubUrlValid(url.href) &&
162 validator.isInt(url.width + '', { min: 0 }) 165 validator.isInt(url.height + '', { min: 0 })
163 ) || 166 ) ||
164 ( 167 (
165 ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && 168 ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 &&
166 validator.isLength(url.href, { min: 5 }) && 169 validator.isLength(url.href, { min: 5 }) &&
167 validator.isInt(url.width + '', { min: 0 }) 170 validator.isInt(url.height + '', { min: 0 })
168 ) 171 )
169} 172}