aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-17 11:35:10 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commitafffe98839db7ccbfa9fb8b7d1413b97900fdc73 (patch)
treef0b3cbe58f73e81a5ba4bb31dabd9691994cf2ca /server/helpers
parent1b3989b0961d22a5a45ad16239e3c3f58f66180c (diff)
downloadPeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.tar.gz
PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.tar.zst
PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.zip
Speed up activity pub http requests
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/activitypub.ts11
1 files changed, 10 insertions, 1 deletions
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'
3import * as Sequelize from 'sequelize' 3import * as Sequelize from 'sequelize'
4import * as url from 'url' 4import * as url from 'url'
5import { ActivityIconObject } from '../../shared/index' 5import { ActivityIconObject } from '../../shared/index'
6import { Activity } from '../../shared/models/activitypub/activity'
6import { ActivityPubActor } from '../../shared/models/activitypub/activitypub-actor' 7import { ActivityPubActor } from '../../shared/models/activitypub/activitypub-actor'
7import { VideoChannelObject } from '../../shared/models/activitypub/objects/video-channel-object' 8import { VideoChannelObject } from '../../shared/models/activitypub/objects/video-channel-object'
8import { ResultList } from '../../shared/models/result-list.model' 9import { ResultList } from '../../shared/models/result-list.model'
@@ -17,6 +18,7 @@ import { VideoInstance } from '../models/video/video-interface'
17import { isRemoteAccountValid } from './custom-validators' 18import { isRemoteAccountValid } from './custom-validators'
18import { isVideoChannelObjectValid } from './custom-validators/activitypub/videos' 19import { isVideoChannelObjectValid } from './custom-validators/activitypub/videos'
19import { logger } from './logger' 20import { logger } from './logger'
21import { signObject } from './peertube-crypto'
20import { doRequest, doRequestAndSaveToFile } from './requests' 22import { doRequest, doRequestAndSaveToFile } from './requests'
21import { getServerAccount } from './utils' 23import { getServerAccount } from './utils'
22 24
@@ -239,6 +241,12 @@ function activityPubCollectionPagination (url: string, page: number, result: Res
239 return activityPubContextify(obj) 241 return activityPubContextify(obj)
240} 242}
241 243
244function buildSignedActivity (byAccount: AccountInstance, data: Object) {
245 const activity = activityPubContextify(data)
246
247 return signObject(byAccount, activity) as Promise<Activity>
248}
249
242// --------------------------------------------------------------------------- 250// ---------------------------------------------------------------------------
243 251
244export { 252export {
@@ -252,7 +260,8 @@ export {
252 fetchRemoteVideoDescription, 260 fetchRemoteVideoDescription,
253 shareVideoChannelByServer, 261 shareVideoChannelByServer,
254 shareVideoByServer, 262 shareVideoByServer,
255 getOrCreateVideoChannel 263 getOrCreateVideoChannel,
264 buildSignedActivity
256} 265}
257 266
258// --------------------------------------------------------------------------- 267// ---------------------------------------------------------------------------