From bbcd6d11ba4d5c35df752149f82ff21d41a1b076 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 18 Dec 2024 13:08:22 +0900 Subject: [PATCH] fix: unable to cross-domain lookup --- CHANGELOG.md | 2 +- .../backend/src/core/activitypub/ApResolverService.ts | 8 +++++--- packages/backend/src/server/api/endpoints/ap/show.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee82834de7..9766dff1da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 2024.11.1 ### General -- +- ドメインをまたいだ照会ができない問題を修正 ### Client - Enhance: PC画面でチャンネルが複数列で表示されるように diff --git a/packages/backend/src/core/activitypub/ApResolverService.ts b/packages/backend/src/core/activitypub/ApResolverService.ts index b0b35274ea..b310b0e757 100644 --- a/packages/backend/src/core/activitypub/ApResolverService.ts +++ b/packages/backend/src/core/activitypub/ApResolverService.ts @@ -71,7 +71,7 @@ export class Resolver { } @bindThis - public async resolve(value: string | IObject): Promise { + public async resolve(value: string | IObject, allowHostMismatch = false): Promise { if (typeof value !== 'string') { return value; } @@ -126,8 +126,10 @@ export class Resolver { throw new Error('invalid AP object: missing id'); } - if (this.utilityService.punyHost(object.id) !== this.utilityService.punyHost(value)) { - throw new Error(`invalid AP object ${value}: id ${object.id} has different host`); + if (!allowHostMismatch) { + if (this.utilityService.punyHost(object.id) !== this.utilityService.punyHost(value)) { + throw new Error(`invalid AP object ${value}: id ${object.id} has different host`); + } } return object; diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index 24d5a7b0f1..00d3bfd807 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -125,7 +125,7 @@ export default class extends Endpoint { // eslint- // リモートから一旦オブジェクトフェッチ const resolver = this.apResolverService.createResolver(); - const object = await resolver.resolve(uri) as any; + const object = await resolver.resolve(uri, true) as any; // /@user のような正規id以外で取得できるURIが指定されていた場合、ここで初めて正規URIが確定する // これはDBに存在する可能性があるため再度DB検索