Fix communication with mastodon
This commit is contained in:
parent
bd37753083
commit
9fb3abfdac
|
@ -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 })
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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 ],
|
||||
|
|
|
@ -920,7 +920,7 @@ export class VideoModel extends Model<VideoModel> {
|
|||
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<VideoModel> {
|
|||
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<VideoModel> {
|
|||
url.push({
|
||||
type: 'Link',
|
||||
mimeType: 'text/html',
|
||||
url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid
|
||||
href: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid
|
||||
})
|
||||
|
||||
return {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue