1 import { doRequest } from '../../../server/helpers/requests'
2 import { HTTP_SIGNATURE } from '../../../server/initializers/constants'
3 import { buildGlobalHeaders } from '../../../server/lib/job-queue/handlers/utils/activitypub-http-utils'
4 import { activityPubContextify } from '../../../server/helpers/activitypub'
6 function makePOSTAPRequest (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 makePOSTAPRequest(to.url, body, httpSignature, headers)