From 9fb3abfdac5c4bffe9992a457e5210d3aa743952 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Jan 2018 15:35:30 +0100 Subject: [PATCH] Fix communication with mastodon --- server/helpers/custom-validators/activitypub/videos.ts | 6 +++--- server/lib/activitypub/videos.ts | 6 +++--- server/models/video/video.ts | 8 ++++---- shared/models/activitypub/objects/common-objects.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index fb1d2d094..5d2a1f171 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts @@ -115,18 +115,18 @@ function isRemoteVideoUrlValid (url: any) { return url.type === 'Link' && ( ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && - isActivityPubUrlValid(url.url) && + isActivityPubUrlValid(url.href) && validator.isInt(url.width + '', { min: 0 }) && validator.isInt(url.size + '', { min: 0 }) ) || ( ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && - isActivityPubUrlValid(url.url) && + isActivityPubUrlValid(url.href) && validator.isInt(url.width + '', { min: 0 }) ) || ( ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && - validator.isLength(url.url, { min: 5 }) && + validator.isLength(url.href, { min: 5 }) && validator.isInt(url.width + '', { min: 0 }) ) } diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 708f4a897..5b429709f 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -122,10 +122,10 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width }) - if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.url) + if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) - const parsed = magnetUtil.decode(magnet.url) - if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.url) + const parsed = magnetUtil.decode(magnet.href) + if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.href) const attribute = { extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ], diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 391568df4..3e2b4ce64 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -920,7 +920,7 @@ export class VideoModel extends Model { url.push({ type: 'Link', mimeType: 'video/' + file.extname.replace('.', ''), - url: this.getVideoFileUrl(file, baseUrlHttp), + href: this.getVideoFileUrl(file, baseUrlHttp), width: file.resolution, size: file.size }) @@ -928,14 +928,14 @@ export class VideoModel extends Model { url.push({ type: 'Link', mimeType: 'application/x-bittorrent', - url: this.getTorrentUrl(file, baseUrlHttp), + href: this.getTorrentUrl(file, baseUrlHttp), width: file.resolution }) url.push({ type: 'Link', mimeType: 'application/x-bittorrent;x-scheme-handler/magnet', - url: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs), + href: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs), width: file.resolution }) } @@ -944,7 +944,7 @@ export class VideoModel extends Model { url.push({ type: 'Link', mimeType: 'text/html', - url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid + href: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid }) return { diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index aef728b82..3127d0565 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts @@ -20,7 +20,7 @@ export interface ActivityIconObject { export interface ActivityUrlObject { type: 'Link' mimeType: 'video/mp4' | 'video/webm' | 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' - url: string + href: string width: number size?: number }