X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Factivitypub.ts;h=08aef29083dbb14a3753cf121b41f6d1c4dae275;hb=1dae95d7e2405c7b819daa24acde8ac5a754baf5;hp=2d49e6869d690adb75b838df41fdbea0c582a2bf;hpb=338eb9d33af690db716805fd2277bf68f473b58f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 2d49e6869..08aef2908 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -1,14 +1,13 @@ import * as Bluebird from 'bluebird' +import { URL } from 'url' import validator from 'validator' +import { ContextType } from '@shared/models/activitypub/context' import { ResultList } from '../../shared/models' import { Activity } from '../../shared/models/activitypub' import { ACTIVITY_PUB, REMOTE_SCHEME } from '../initializers/constants' -import { signJsonLDObject } from './peertube-crypto' +import { MActor, MVideoWithHost } from '../types/models' import { pageToStartAndCount } from './core-utils' -import { URL } from 'url' -import { MActor, MVideoAccountLight } from '../typings/models' - -export type ContextType = 'All' | 'View' | 'Announce' | 'CacheFile' +import { signJsonLDObject } from './peertube-crypto' function getContextData (type: ContextType) { const context: any[] = [ @@ -40,7 +39,20 @@ function getContextData (type: ContextType) { sensitive: 'as:sensitive', language: 'sc:inLanguage', + isLiveBroadcast: 'sc:isLiveBroadcast', + liveSaveReplay: { + '@type': 'sc:Boolean', + '@id': 'pt:liveSaveReplay' + }, + permanentLive: { + '@type': 'sc:Boolean', + '@id': 'pt:permanentLive' + }, + Infohash: 'pt:Infohash', + Playlist: 'pt:Playlist', + PlaylistElement: 'pt:PlaylistElement', + originallyPublishedAt: 'sc:datePublished', views: { '@type': 'sc:Number', @@ -189,10 +201,12 @@ function checkUrlsSameHost (url1: string, url2: string) { return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase() } -function buildRemoteVideoBaseUrl (video: MVideoAccountLight, path: string) { - const host = video.VideoChannel.Account.Actor.Server.host +function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) { + if (!scheme) scheme = REMOTE_SCHEME.HTTP + + const host = video.VideoChannel.Actor.Server.host - return REMOTE_SCHEME.HTTP + '://' + host + path + return scheme + '://' + host + path } // ---------------------------------------------------------------------------