From afffe98839db7ccbfa9fb8b7d1413b97900fdc73 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Nov 2017 11:35:10 +0100 Subject: Speed up activity pub http requests --- server/helpers/activitypub.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index c710117cd..338698652 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -3,6 +3,7 @@ import * as request from 'request' import * as Sequelize from 'sequelize' import * as url from 'url' import { ActivityIconObject } from '../../shared/index' +import { Activity } from '../../shared/models/activitypub/activity' import { ActivityPubActor } from '../../shared/models/activitypub/activitypub-actor' import { VideoChannelObject } from '../../shared/models/activitypub/objects/video-channel-object' import { ResultList } from '../../shared/models/result-list.model' @@ -17,6 +18,7 @@ import { VideoInstance } from '../models/video/video-interface' import { isRemoteAccountValid } from './custom-validators' import { isVideoChannelObjectValid } from './custom-validators/activitypub/videos' import { logger } from './logger' +import { signObject } from './peertube-crypto' import { doRequest, doRequestAndSaveToFile } from './requests' import { getServerAccount } from './utils' @@ -239,6 +241,12 @@ function activityPubCollectionPagination (url: string, page: number, result: Res return activityPubContextify(obj) } +function buildSignedActivity (byAccount: AccountInstance, data: Object) { + const activity = activityPubContextify(data) + + return signObject(byAccount, activity) as Promise +} + // --------------------------------------------------------------------------- export { @@ -252,7 +260,8 @@ export { fetchRemoteVideoDescription, shareVideoChannelByServer, shareVideoByServer, - getOrCreateVideoChannel + getOrCreateVideoChannel, + buildSignedActivity } // --------------------------------------------------------------------------- -- cgit v1.2.3