aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts7
-rw-r--r--server/lib/activitypub/videos.ts9
-rw-r--r--server/models/redundancy/video-redundancy.ts1
-rw-r--r--server/models/video/video-format-utils.ts4
4 files changed, 15 insertions, 6 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index f88d26561..95fe824b9 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -81,19 +81,20 @@ function isRemoteVideoUrlValid (url: any) {
81 81
82 return url.type === 'Link' && 82 return url.type === 'Link' &&
83 ( 83 (
84 ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && 84 // TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
85 ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mediaType || url.mimeType) !== -1 &&
85 isActivityPubUrlValid(url.href) && 86 isActivityPubUrlValid(url.href) &&
86 validator.isInt(url.height + '', { min: 0 }) && 87 validator.isInt(url.height + '', { min: 0 }) &&
87 validator.isInt(url.size + '', { min: 0 }) && 88 validator.isInt(url.size + '', { min: 0 }) &&
88 (!url.fps || validator.isInt(url.fps + '', { min: -1 })) 89 (!url.fps || validator.isInt(url.fps + '', { min: -1 }))
89 ) || 90 ) ||
90 ( 91 (
91 ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && 92 ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mediaType || url.mimeType) !== -1 &&
92 isActivityPubUrlValid(url.href) && 93 isActivityPubUrlValid(url.href) &&
93 validator.isInt(url.height + '', { min: 0 }) 94 validator.isInt(url.height + '', { min: 0 })
94 ) || 95 ) ||
95 ( 96 (
96 ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && 97 ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mediaType || url.mimeType) !== -1 &&
97 validator.isLength(url.href, { min: 5 }) && 98 validator.isLength(url.href, { min: 5 }) &&
98 validator.isInt(url.height + '', { min: 0 }) 99 validator.isInt(url.height + '', { min: 0 })
99 ) 100 )
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 54cea542f..3da363c0a 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -310,7 +310,8 @@ export {
310function isActivityVideoUrlObject (url: ActivityUrlObject): url is ActivityVideoUrlObject { 310function isActivityVideoUrlObject (url: ActivityUrlObject): url is ActivityVideoUrlObject {
311 const mimeTypes = Object.keys(VIDEO_MIMETYPE_EXT) 311 const mimeTypes = Object.keys(VIDEO_MIMETYPE_EXT)
312 312
313 return mimeTypes.indexOf(url.mimeType) !== -1 && url.mimeType.startsWith('video/') 313 const urlMediaType = url.mediaType || url.mimeType
314 return mimeTypes.indexOf(urlMediaType) !== -1 && urlMediaType.startsWith('video/')
314} 315}
315 316
316async function createVideo (videoObject: VideoTorrentObject, channelActor: ActorModel, waitThumbnail = false) { 317async function createVideo (videoObject: VideoTorrentObject, channelActor: ActorModel, waitThumbnail = false) {
@@ -468,7 +469,8 @@ function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: Vid
468 for (const fileUrl of fileUrls) { 469 for (const fileUrl of fileUrls) {
469 // Fetch associated magnet uri 470 // Fetch associated magnet uri
470 const magnet = videoObject.url.find(u => { 471 const magnet = videoObject.url.find(u => {
471 return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.height === fileUrl.height 472 const mediaType = u.mediaType || u.mimeType
473 return mediaType === 'application/x-bittorrent;x-scheme-handler/magnet' && (u as any).height === fileUrl.height
472 }) 474 })
473 475
474 if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) 476 if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href)
@@ -478,8 +480,9 @@ function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: Vid
478 throw new Error('Cannot parse magnet URI ' + magnet.href) 480 throw new Error('Cannot parse magnet URI ' + magnet.href)
479 } 481 }
480 482
483 const mediaType = fileUrl.mediaType || fileUrl.mimeType
481 const attribute = { 484 const attribute = {
482 extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ], 485 extname: VIDEO_MIMETYPE_EXT[ mediaType ],
483 infoHash: parsed.infoHash, 486 infoHash: parsed.infoHash,
484 resolution: fileUrl.height, 487 resolution: fileUrl.height,
485 size: fileUrl.size, 488 size: fileUrl.size,
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index 2ebe23ef1..cbfc7f7fa 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -408,6 +408,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
408 url: { 408 url: {
409 type: 'Link', 409 type: 'Link',
410 mimeType: VIDEO_EXT_MIMETYPE[ this.VideoFile.extname ] as any, 410 mimeType: VIDEO_EXT_MIMETYPE[ this.VideoFile.extname ] as any,
411 mediaType: VIDEO_EXT_MIMETYPE[ this.VideoFile.extname ] as any,
411 href: this.fileUrl, 412 href: this.fileUrl,
412 height: this.VideoFile.resolution, 413 height: this.VideoFile.resolution,
413 size: this.VideoFile.size, 414 size: this.VideoFile.size,
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index 905e84449..e3f8d525b 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -208,6 +208,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
208 url.push({ 208 url.push({
209 type: 'Link', 209 type: 'Link',
210 mimeType: VIDEO_EXT_MIMETYPE[ file.extname ] as any, 210 mimeType: VIDEO_EXT_MIMETYPE[ file.extname ] as any,
211 mediaType: VIDEO_EXT_MIMETYPE[ file.extname ] as any,
211 href: video.getVideoFileUrl(file, baseUrlHttp), 212 href: video.getVideoFileUrl(file, baseUrlHttp),
212 height: file.resolution, 213 height: file.resolution,
213 size: file.size, 214 size: file.size,
@@ -217,6 +218,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
217 url.push({ 218 url.push({
218 type: 'Link', 219 type: 'Link',
219 mimeType: 'application/x-bittorrent' as 'application/x-bittorrent', 220 mimeType: 'application/x-bittorrent' as 'application/x-bittorrent',
221 mediaType: 'application/x-bittorrent' as 'application/x-bittorrent',
220 href: video.getTorrentUrl(file, baseUrlHttp), 222 href: video.getTorrentUrl(file, baseUrlHttp),
221 height: file.resolution 223 height: file.resolution
222 }) 224 })
@@ -224,6 +226,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
224 url.push({ 226 url.push({
225 type: 'Link', 227 type: 'Link',
226 mimeType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet', 228 mimeType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
229 mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
227 href: video.generateMagnetUri(file, baseUrlHttp, baseUrlWs), 230 href: video.generateMagnetUri(file, baseUrlHttp, baseUrlWs),
228 height: file.resolution 231 height: file.resolution
229 }) 232 })
@@ -233,6 +236,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
233 url.push({ 236 url.push({
234 type: 'Link', 237 type: 'Link',
235 mimeType: 'text/html', 238 mimeType: 'text/html',
239 mediaType: 'text/html',
236 href: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid 240 href: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
237 }) 241 })
238 242