fix: unable to cross-domain lookup

This commit is contained in:
anatawa12 2024-12-18 13:08:22 +09:00
parent 0804092426
commit bbcd6d11ba
No known key found for this signature in database
GPG key ID: 9CA909848B8E4EA6
3 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,7 @@
## 2024.11.1
### General
-
- ドメインをまたいだ照会ができない問題を修正
### Client
- Enhance: PC画面でチャンネルが複数列で表示されるように

View file

@ -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;
}
@ -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;

View file

@ -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検索