mirror of https://github.com/Chocobozzz/PeerTube
Fix communication with mastodon
parent
bd37753083
commit
9fb3abfdac
|
@ -115,18 +115,18 @@ function isRemoteVideoUrlValid (url: any) {
|
||||||
return url.type === 'Link' &&
|
return url.type === 'Link' &&
|
||||||
(
|
(
|
||||||
ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 &&
|
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.width + '', { min: 0 }) &&
|
||||||
validator.isInt(url.size + '', { min: 0 })
|
validator.isInt(url.size + '', { min: 0 })
|
||||||
) ||
|
) ||
|
||||||
(
|
(
|
||||||
ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
|
ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
|
||||||
isActivityPubUrlValid(url.url) &&
|
isActivityPubUrlValid(url.href) &&
|
||||||
validator.isInt(url.width + '', { min: 0 })
|
validator.isInt(url.width + '', { min: 0 })
|
||||||
) ||
|
) ||
|
||||||
(
|
(
|
||||||
ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 &&
|
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 })
|
validator.isInt(url.width + '', { min: 0 })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,10 +122,10 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
|
||||||
return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width
|
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)
|
const parsed = magnetUtil.decode(magnet.href)
|
||||||
if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.url)
|
if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) throw new Error('Cannot parse magnet URI ' + magnet.href)
|
||||||
|
|
||||||
const attribute = {
|
const attribute = {
|
||||||
extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ],
|
extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ],
|
||||||
|
|
|
@ -920,7 +920,7 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
url.push({
|
url.push({
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'video/' + file.extname.replace('.', ''),
|
mimeType: 'video/' + file.extname.replace('.', ''),
|
||||||
url: this.getVideoFileUrl(file, baseUrlHttp),
|
href: this.getVideoFileUrl(file, baseUrlHttp),
|
||||||
width: file.resolution,
|
width: file.resolution,
|
||||||
size: file.size
|
size: file.size
|
||||||
})
|
})
|
||||||
|
@ -928,14 +928,14 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
url.push({
|
url.push({
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'application/x-bittorrent',
|
mimeType: 'application/x-bittorrent',
|
||||||
url: this.getTorrentUrl(file, baseUrlHttp),
|
href: this.getTorrentUrl(file, baseUrlHttp),
|
||||||
width: file.resolution
|
width: file.resolution
|
||||||
})
|
})
|
||||||
|
|
||||||
url.push({
|
url.push({
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'application/x-bittorrent;x-scheme-handler/magnet',
|
mimeType: 'application/x-bittorrent;x-scheme-handler/magnet',
|
||||||
url: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs),
|
href: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs),
|
||||||
width: file.resolution
|
width: file.resolution
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -944,7 +944,7 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
url.push({
|
url.push({
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mimeType: 'text/html',
|
mimeType: 'text/html',
|
||||||
url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid
|
href: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export interface ActivityIconObject {
|
||||||
export interface ActivityUrlObject {
|
export interface ActivityUrlObject {
|
||||||
type: 'Link'
|
type: 'Link'
|
||||||
mimeType: 'video/mp4' | 'video/webm' | 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
|
mimeType: 'video/mp4' | 'video/webm' | 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
|
||||||
url: string
|
href: string
|
||||||
width: number
|
width: number
|
||||||
size?: number
|
size?: number
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue