Skip to content

Commit

Permalink
fix: unable to cross-domain lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Dec 18, 2024
1 parent 0804092 commit bbcd6d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## 2024.11.1

### General
-
- ドメインをまたいだ照会ができない問題を修正

### Client
- Enhance: PC画面でチャンネルが複数列で表示されるように
Expand Down
8 changes: 5 additions & 3 deletions packages/backend/src/core/activitypub/ApResolverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Resolver {
}

@bindThis
public async resolve(value: string | IObject): Promise<IObject> {
public async resolve(value: string | IObject, allowHostMismatch = false): Promise<IObject> {
if (typeof value !== 'string') {
return value;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/ap/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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検索
Expand Down

0 comments on commit bbcd6d1

Please sign in to comment.