mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-13 09:10:47 +01:00
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
3 changed files with 23 additions and 4 deletions
|
@ -79,6 +79,7 @@
|
|||
|
||||
### Server
|
||||
- Fix: キャッシュが溜まり続けないように
|
||||
- Fix: ローカルの `Person` を指す `acct` URI を解析するときのバグを修正しました
|
||||
|
||||
## 13.13.1
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@ import type { LocalUser, RemoteUser } from '@/models/entities/User.js';
|
|||
import type { Config } from '@/config.js';
|
||||
import type Logger from '@/logger.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 { ApDbResolverService } from '@/core/activitypub/ApDbResolverService.js';
|
||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
|
@ -27,6 +28,7 @@ export class RemoteUserResolveService {
|
|||
private utilityService: UtilityService,
|
||||
private webfingerService: WebfingerService,
|
||||
private remoteLoggerService: RemoteLoggerService,
|
||||
private apDbResolverService: ApDbResolverService,
|
||||
private apPersonService: ApPersonService,
|
||||
) {
|
||||
this.logger = this.remoteLoggerService.logger.createSubLogger('resolve-user');
|
||||
|
@ -67,6 +69,22 @@ export class RemoteUserResolveService {
|
|||
if (user == null) {
|
||||
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)}`);
|
||||
return await this.apPersonService.createPerson(self.href);
|
||||
}
|
||||
|
@ -119,7 +137,7 @@ export class RemoteUserResolveService {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
private async resolveSelf(acctLower: string) {
|
||||
private async resolveSelf(acctLower: string): Promise<ILink> {
|
||||
this.logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
||||
const finger = await this.webfingerService.webfinger(acctLower).catch(err => {
|
||||
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 { bindThis } from '@/decorators.js';
|
||||
|
||||
type ILink = {
|
||||
export type ILink = {
|
||||
href: string;
|
||||
rel?: string;
|
||||
};
|
||||
|
||||
type IWebFinger = {
|
||||
export type IWebFinger = {
|
||||
links: ILink[];
|
||||
subject: string;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue