forked from mirror/misskey
fix: failed to resolve acct URI which points to local Person (#11024)
* fix: resolving alias for local users (#9199) Signed-off-by: xtex <xtexchooser@duck.com> * style: return type for RemoteUserResolveService#resolveSelf Signed-off-by: xtex <xtexchooser@duck.com> * docs: update CHANGELOG Signed-off-by: xtex <xtexchooser@duck.com> * style: fix typecheck Signed-off-by: xtex <xtexchooser@duck.com> --------- Signed-off-by: xtex <xtexchooser@duck.com> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
5280a5e5c6
commit
bf9e74ca05
@ -79,6 +79,7 @@
|
|||||||
|
|
||||||
### Server
|
### Server
|
||||||
- Fix: キャッシュが溜まり続けないように
|
- Fix: キャッシュが溜まり続けないように
|
||||||
|
- Fix: ローカルの `Person` を指す `acct` URI を解析するときのバグを修正しました
|
||||||
|
|
||||||
## 13.13.1
|
## 13.13.1
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@ import type { LocalUser, RemoteUser } from '@/models/entities/User.js';
|
|||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
import { UtilityService } from '@/core/UtilityService.js';
|
import { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { WebfingerService } from '@/core/WebfingerService.js';
|
import { ILink, WebfingerService } from '@/core/WebfingerService.js';
|
||||||
import { RemoteLoggerService } from '@/core/RemoteLoggerService.js';
|
import { RemoteLoggerService } from '@/core/RemoteLoggerService.js';
|
||||||
|
import { ApDbResolverService } from '@/core/activitypub/ApDbResolverService.js';
|
||||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ export class RemoteUserResolveService {
|
|||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private webfingerService: WebfingerService,
|
private webfingerService: WebfingerService,
|
||||||
private remoteLoggerService: RemoteLoggerService,
|
private remoteLoggerService: RemoteLoggerService,
|
||||||
|
private apDbResolverService: ApDbResolverService,
|
||||||
private apPersonService: ApPersonService,
|
private apPersonService: ApPersonService,
|
||||||
) {
|
) {
|
||||||
this.logger = this.remoteLoggerService.logger.createSubLogger('resolve-user');
|
this.logger = this.remoteLoggerService.logger.createSubLogger('resolve-user');
|
||||||
@ -67,6 +69,22 @@ export class RemoteUserResolveService {
|
|||||||
if (user == null) {
|
if (user == null) {
|
||||||
const self = await this.resolveSelf(acctLower);
|
const self = await this.resolveSelf(acctLower);
|
||||||
|
|
||||||
|
if (self.href.startsWith(this.config.url)) {
|
||||||
|
const local = this.apDbResolverService.parseUri(self.href);
|
||||||
|
if (local.local && local.type === 'users') {
|
||||||
|
// the LR points to local
|
||||||
|
return (await this.apDbResolverService
|
||||||
|
.getUserFromApId(self.href)
|
||||||
|
.then((u) => {
|
||||||
|
if (u == null) {
|
||||||
|
throw new Error('local user not found');
|
||||||
|
} else {
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
})) as LocalUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.succ(`return new remote user: ${chalk.magenta(acctLower)}`);
|
this.logger.succ(`return new remote user: ${chalk.magenta(acctLower)}`);
|
||||||
return await this.apPersonService.createPerson(self.href);
|
return await this.apPersonService.createPerson(self.href);
|
||||||
}
|
}
|
||||||
@ -119,7 +137,7 @@ export class RemoteUserResolveService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async resolveSelf(acctLower: string) {
|
private async resolveSelf(acctLower: string): Promise<ILink> {
|
||||||
this.logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
this.logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
||||||
const finger = await this.webfingerService.webfinger(acctLower).catch(err => {
|
const finger = await this.webfingerService.webfinger(acctLower).catch(err => {
|
||||||
this.logger.error(`Failed to WebFinger for ${chalk.yellow(acctLower)}: ${ err.statusCode ?? err.message }`);
|
this.logger.error(`Failed to WebFinger for ${chalk.yellow(acctLower)}: ${ err.statusCode ?? err.message }`);
|
||||||
|
@ -6,12 +6,12 @@ import { query as urlQuery } from '@/misc/prelude/url.js';
|
|||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
||||||
type ILink = {
|
export type ILink = {
|
||||||
href: string;
|
href: string;
|
||||||
rel?: string;
|
rel?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IWebFinger = {
|
export type IWebFinger = {
|
||||||
links: ILink[];
|
links: ILink[];
|
||||||
subject: string;
|
subject: string;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user