diff options
Diffstat (limited to 'shared/extra-utils/requests')
-rw-r--r-- | shared/extra-utils/requests/activitypub.ts | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/shared/extra-utils/requests/activitypub.ts b/shared/extra-utils/requests/activitypub.ts deleted file mode 100644 index 4ae878384..000000000 --- a/shared/extra-utils/requests/activitypub.ts +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | import { activityPubContextify } from '../../../server/helpers/activitypub' | ||
2 | import { doRequest } from '../../../server/helpers/requests' | ||
3 | import { HTTP_SIGNATURE } from '../../../server/initializers/constants' | ||
4 | import { buildGlobalHeaders } from '../../../server/lib/job-queue/handlers/utils/activitypub-http-utils' | ||
5 | |||
6 | function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { | ||
7 | const options = { | ||
8 | method: 'POST' as 'POST', | ||
9 | json: body, | ||
10 | httpSignature, | ||
11 | headers | ||
12 | } | ||
13 | |||
14 | return doRequest(url, options) | ||
15 | } | ||
16 | |||
17 | async function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) { | ||
18 | const follow = { | ||
19 | type: 'Follow', | ||
20 | id: by.url + '/' + new Date().getTime(), | ||
21 | actor: by.url, | ||
22 | object: to.url | ||
23 | } | ||
24 | |||
25 | const body = activityPubContextify(follow) | ||
26 | |||
27 | const httpSignature = { | ||
28 | algorithm: HTTP_SIGNATURE.ALGORITHM, | ||
29 | authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, | ||
30 | keyId: by.url, | ||
31 | key: by.privateKey, | ||
32 | headers: HTTP_SIGNATURE.HEADERS_TO_SIGN | ||
33 | } | ||
34 | const headers = buildGlobalHeaders(body) | ||
35 | |||
36 | return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers) | ||
37 | } | ||
38 | |||
39 | export { | ||
40 | makePOSTAPRequest, | ||
41 | makeFollowRequest | ||
42 | } | ||