+function getAnnounceWithoutContext (server: PeerTubeServer) {
+ const json = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json'))
+ const result: typeof json = {}
+
+ for (const key of Object.keys(json)) {
+ if (Array.isArray(json[key])) {
+ result[key] = json[key].map(v => v.replace(':9002', `:${server.port}`))
+ } else {
+ result[key] = json[key].replace(':9002', `:${server.port}`)
+ }
+ }
+
+ return result
+}
+
+async function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) {
+ const follow = {
+ type: 'Follow',
+ id: by.url + '/' + new Date().getTime(),
+ actor: by.url,
+ object: to.url
+ }
+
+ const body = await activityPubContextify(follow, 'Follow')
+
+ const httpSignature = {
+ algorithm: HTTP_SIGNATURE.ALGORITHM,
+ authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
+ keyId: by.url,
+ key: by.privateKey,
+ headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
+ }
+ const headers = {
+ 'digest': buildDigest(body),
+ 'content-type': 'application/activity+json',
+ 'accept': ACTIVITY_PUB.ACCEPT_HEADER
+ }
+
+ return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers)
+}
+