diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-12 15:35:30 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-12 15:35:30 +0100 |
commit | 9fb3abfdac5c4bffe9992a457e5210d3aa743952 (patch) | |
tree | b2feaec75e890ea842dcb52b9760863cd64481fb /server | |
parent | bd377530836474fa2a4404bd3e8bdd15f1b9ccc0 (diff) | |
download | PeerTube-9fb3abfdac5c4bffe9992a457e5210d3aa743952.tar.gz PeerTube-9fb3abfdac5c4bffe9992a457e5210d3aa743952.tar.zst PeerTube-9fb3abfdac5c4bffe9992a457e5210d3aa743952.zip |
Fix communication with mastodon
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 6 | ||||
-rw-r--r-- | server/models/video/video.ts | 8 |
3 files changed, 10 insertions, 10 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) { | |||
115 | return url.type === 'Link' && | 115 | return url.type === 'Link' && |
116 | ( | 116 | ( |
117 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && | 117 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && |
118 | isActivityPubUrlValid(url.url) && | 118 | isActivityPubUrlValid(url.href) && |
119 | validator.isInt(url.width + '', { min: 0 }) && | 119 | validator.isInt(url.width + '', { min: 0 }) && |
120 | validator.isInt(url.size + '', { min: 0 }) | 120 | validator.isInt(url.size + '', { min: 0 }) |
121 | ) || | 121 | ) || |
122 | ( | 122 | ( |
123 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && | 123 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && |
124 | isActivityPubUrlValid(url.url) && | 124 | isActivityPubUrlValid(url.href) && |
125 | validator.isInt(url.width + '', { min: 0 }) | 125 | validator.isInt(url.width + '', { min: 0 }) |
126 | ) || | 126 | ) || |
127 | ( | 127 | ( |
128 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && | 128 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && |
129 | validator.isLength(url.url, { min: 5 }) && | 129 | validator.isLength(url.href, { min: 5 }) && |
130 | validator.isInt(url.width + '', { min: 0 }) | 130 | validator.isInt(url.width + '', { min: 0 }) |
131 | ) | 131 | ) |
132 | } | 132 | } |
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 | |||
122 | return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width | 122 | return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width |
123 | }) | 123 | }) |
124 | 124 | ||
125 | if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.url) | 125 | if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) |
126 | 126 | ||
127 | const parsed = magnetUtil.decode(magnet.url) | 127 | const parsed = magnetUtil.decode(magnet.href) |
128 | if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.url) | 128 | if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.href) |
129 | 129 | ||
130 | const attribute = { | 130 | const attribute = { |
131 | extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ], | 131 | 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<VideoModel> { | |||
920 | url.push({ | 920 | url.push({ |
921 | type: 'Link', | 921 | type: 'Link', |
922 | mimeType: 'video/' + file.extname.replace('.', ''), | 922 | mimeType: 'video/' + file.extname.replace('.', ''), |
923 | url: this.getVideoFileUrl(file, baseUrlHttp), | 923 | href: this.getVideoFileUrl(file, baseUrlHttp), |
924 | width: file.resolution, | 924 | width: file.resolution, |
925 | size: file.size | 925 | size: file.size |
926 | }) | 926 | }) |
@@ -928,14 +928,14 @@ export class VideoModel extends Model<VideoModel> { | |||
928 | url.push({ | 928 | url.push({ |
929 | type: 'Link', | 929 | type: 'Link', |
930 | mimeType: 'application/x-bittorrent', | 930 | mimeType: 'application/x-bittorrent', |
931 | url: this.getTorrentUrl(file, baseUrlHttp), | 931 | href: this.getTorrentUrl(file, baseUrlHttp), |
932 | width: file.resolution | 932 | width: file.resolution |
933 | }) | 933 | }) |
934 | 934 | ||
935 | url.push({ | 935 | url.push({ |
936 | type: 'Link', | 936 | type: 'Link', |
937 | mimeType: 'application/x-bittorrent;x-scheme-handler/magnet', | 937 | mimeType: 'application/x-bittorrent;x-scheme-handler/magnet', |
938 | url: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs), | 938 | href: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs), |
939 | width: file.resolution | 939 | width: file.resolution |
940 | }) | 940 | }) |
941 | } | 941 | } |
@@ -944,7 +944,7 @@ export class VideoModel extends Model<VideoModel> { | |||
944 | url.push({ | 944 | url.push({ |
945 | type: 'Link', | 945 | type: 'Link', |
946 | mimeType: 'text/html', | 946 | mimeType: 'text/html', |
947 | url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid | 947 | href: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid |
948 | }) | 948 | }) |
949 | 949 | ||
950 | return { | 950 | return { |