diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-24 13:41:10 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | 63c93323ecdeaa4b6183d75dd3f13469e1ef3ebd (patch) | |
tree | 3ee4b351025d4b19f6e880754df44fa7605b683d /server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts | |
parent | d4f1e94c89336255537b0b82913591f00e716201 (diff) | |
download | PeerTube-63c93323ecdeaa4b6183d75dd3f13469e1ef3ebd.tar.gz PeerTube-63c93323ecdeaa4b6183d75dd3f13469e1ef3ebd.tar.zst PeerTube-63c93323ecdeaa4b6183d75dd3f13469e1ef3ebd.zip |
Correctly forward like/dislikes and undo
Diffstat (limited to 'server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts')
-rw-r--r-- | server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts index ccf109935..f1fe774cc 100644 --- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts +++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts | |||
@@ -1,11 +1,13 @@ | |||
1 | import { JobScheduler, JobHandler } from '../job-scheduler' | 1 | import { JobCategory } from '../../../../shared' |
2 | import { buildSignedActivity } from '../../../helpers/activitypub' | ||
3 | import { logger } from '../../../helpers/logger' | ||
4 | import { ACTIVITY_PUB } from '../../../initializers/constants' | ||
5 | import { database as db } from '../../../initializers/database' | ||
6 | import { JobHandler, JobScheduler } from '../job-scheduler' | ||
2 | 7 | ||
3 | import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler' | 8 | import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler' |
4 | import * as activitypubHttpUnicastHandler from './activitypub-http-unicast-handler' | ||
5 | import * as activitypubHttpFetcherHandler from './activitypub-http-fetcher-handler' | 9 | import * as activitypubHttpFetcherHandler from './activitypub-http-fetcher-handler' |
6 | import { JobCategory } from '../../../../shared' | 10 | import * as activitypubHttpUnicastHandler from './activitypub-http-unicast-handler' |
7 | import { ACTIVITY_PUB } from '../../../initializers/constants' | ||
8 | import { logger } from '../../../helpers/logger' | ||
9 | 11 | ||
10 | type ActivityPubHttpPayload = { | 12 | type ActivityPubHttpPayload = { |
11 | uris: string[] | 13 | uris: string[] |
@@ -40,8 +42,21 @@ function maybeRetryRequestLater (err: Error, payload: ActivityPubHttpPayload, ur | |||
40 | } | 42 | } |
41 | } | 43 | } |
42 | 44 | ||
45 | async function computeBody (payload: ActivityPubHttpPayload) { | ||
46 | let body = payload.body | ||
47 | |||
48 | if (payload.signatureAccountId) { | ||
49 | const accountSignature = await db.Account.load(payload.signatureAccountId) | ||
50 | if (!accountSignature) throw new Error('Unknown signature account id.') | ||
51 | body = await buildSignedActivity(accountSignature, payload.body) | ||
52 | } | ||
53 | |||
54 | return body | ||
55 | } | ||
56 | |||
43 | export { | 57 | export { |
44 | ActivityPubHttpPayload, | 58 | ActivityPubHttpPayload, |
45 | activitypubHttpJobScheduler, | 59 | activitypubHttpJobScheduler, |
46 | maybeRetryRequestLater | 60 | maybeRetryRequestLater, |
61 | computeBody | ||
47 | } | 62 | } |