1 import { doRequest } from '../../../helpers/requests'
2 import { HTTP_SIGNATURE } from '../../../initializers'
3 import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
4 import { activityPubContextify } from '../../../helpers/activitypub'
6 function makeAPRequest (url: string, body: any, httpSignature: any, headers: any) {
15 return doRequest(options)
18 async function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) {
26 const body = activityPubContextify(follow)
28 const httpSignature = {
29 algorithm: HTTP_SIGNATURE.ALGORITHM,
30 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
33 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
35 const headers = buildGlobalHeaders(body)
37 return makeAPRequest(to.url, body, httpSignature, headers)