From 85a0f696bcea779b02749dae596fff94a1df2467 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 18 Oct 2020 01:46:40 +0900 Subject: ActivityPubでリモートのオブジェクトをGETするときのリクエストをHTTP Signatureで署名するオプション (#6731) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Sign ActivityPub GET * Fix v12, v12.48.0 UI bug --- src/remote/activitypub/resolver.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/remote/activitypub/resolver.ts') diff --git a/src/remote/activitypub/resolver.ts b/src/remote/activitypub/resolver.ts index f4bf8f94f9..2871c1cb41 100644 --- a/src/remote/activitypub/resolver.ts +++ b/src/remote/activitypub/resolver.ts @@ -1,8 +1,13 @@ +import config from '../../config'; import { getJson } from '../../misc/fetch'; +import { ILocalUser } from '../../models/entities/user'; +import { getInstanceActor } from '../../services/instance-actor'; +import { signedGet } from './request'; import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type'; export default class Resolver { private history: Set; + private user?: ILocalUser; constructor() { this.history = new Set(); @@ -39,7 +44,13 @@ export default class Resolver { this.history.add(value); - const object = await getJson(value, 'application/activity+json, application/ld+json'); + if (config.signToActivityPubGet && !this.user) { + this.user = await getInstanceActor(); + } + + const object = this.user + ? await signedGet(value, this.user) + : await getJson(value, 'application/activity+json, application/ld+json'); if (object == null || ( Array.isArray(object['@context']) ? -- cgit v1.2.3-freya