X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Factivitypub.ts;h=e0754b501b2ce39729997c298942c20a81f9fb89;hb=71de85be3beb5f5181e6338b1a7154c8cf65afd4;hp=02a9d40269cd6a7181d922db9854c41c1f5a13b8;hpb=90a8bd305de4153ec21137a73ff482dcc2e3e19b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 02a9d4026..e0754b501 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -3,7 +3,6 @@ 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 { MActor, MVideoWithHost } from '../types/models' import { pageToStartAndCount } from './core-utils' @@ -182,10 +181,10 @@ async function activityPubCollectionPagination ( } -function buildSignedActivity (byActor: MActor, data: Object, contextType?: ContextType) { +function buildSignedActivity (byActor: MActor, data: T, contextType?: ContextType) { const activity = activityPubContextify(data, contextType) - return signJsonLDObject(byActor, activity) as Promise + return signJsonLDObject(byActor, activity) } function getAPId (activity: string | { id: string }) { @@ -201,10 +200,12 @@ function checkUrlsSameHost (url1: string, url2: string) { return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase() } -function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string) { +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 } // ---------------------------------------------------------------------------