diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 11:35:10 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | afffe98839db7ccbfa9fb8b7d1413b97900fdc73 (patch) | |
tree | f0b3cbe58f73e81a5ba4bb31dabd9691994cf2ca /server/helpers | |
parent | 1b3989b0961d22a5a45ad16239e3c3f58f66180c (diff) | |
download | PeerTube-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.ts | 11 |
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' | |||
3 | import * as Sequelize from 'sequelize' | 3 | import * as Sequelize from 'sequelize' |
4 | import * as url from 'url' | 4 | import * as url from 'url' |
5 | import { ActivityIconObject } from '../../shared/index' | 5 | import { ActivityIconObject } from '../../shared/index' |
6 | import { Activity } from '../../shared/models/activitypub/activity' | ||
6 | import { ActivityPubActor } from '../../shared/models/activitypub/activitypub-actor' | 7 | import { ActivityPubActor } from '../../shared/models/activitypub/activitypub-actor' |
7 | import { VideoChannelObject } from '../../shared/models/activitypub/objects/video-channel-object' | 8 | import { VideoChannelObject } from '../../shared/models/activitypub/objects/video-channel-object' |
8 | import { ResultList } from '../../shared/models/result-list.model' | 9 | import { ResultList } from '../../shared/models/result-list.model' |
@@ -17,6 +18,7 @@ import { VideoInstance } from '../models/video/video-interface' | |||
17 | import { isRemoteAccountValid } from './custom-validators' | 18 | import { isRemoteAccountValid } from './custom-validators' |
18 | import { isVideoChannelObjectValid } from './custom-validators/activitypub/videos' | 19 | import { isVideoChannelObjectValid } from './custom-validators/activitypub/videos' |
19 | import { logger } from './logger' | 20 | import { logger } from './logger' |
21 | import { signObject } from './peertube-crypto' | ||
20 | import { doRequest, doRequestAndSaveToFile } from './requests' | 22 | import { doRequest, doRequestAndSaveToFile } from './requests' |
21 | import { getServerAccount } from './utils' | 23 | import { 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 | ||
244 | function 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 | ||
244 | export { | 252 | export { |
@@ -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 | // --------------------------------------------------------------------------- |