ActivityPubでリモートのオブジェクトをGETするときのリクエストをHTTP Signatureで署名するオプション (#6731)
* Sign ActivityPub GET * Fix v12, v12.48.0 UI bug
This commit is contained in:
@@ -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<string>;
|
||||
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']) ?
|
||||
|
Reference in New Issue
Block a user