enhance(backend) : リモートユーザーの照会をオリジナルにリダイレクトするように (#12892)

This commit is contained in:
momoirodouhu 2024-11-06 14:45:29 +00:00
parent a896c39dbf
commit 1356ef425f
No known key found for this signature in database
GPG Key ID: 6D6069FB91D619C0
2 changed files with 23 additions and 4 deletions

View File

@ -35,6 +35,7 @@
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/706)
- Fix: 連合への配信時に、acctの大小文字が区別されてしまい正しくメンションが処理されないことがある問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/711)
- Enhance: リモートユーザーの照会をオリジナルにリダイレクトするように
### Misskey.js
- Fix: Stream初期化時、別途WebSocketを指定する場合の型定義を修正

View File

@ -486,6 +486,16 @@ export class ActivityPubServerService {
return;
}
// リモートだったらリダイレクト
if (user.host != null) {
if (user.uri == null || this.utilityService.isSelfHost(user.host)) {
reply.code(500);
return;
}
reply.redirect(user.uri, 301);
return;
}
reply.header('Cache-Control', 'public, max-age=180');
this.setResponseType(request, reply);
return (this.apRendererService.addContext(await this.apRendererService.renderPerson(user as MiLocalUser)));
@ -654,19 +664,27 @@ export class ActivityPubServerService {
const user = await this.usersRepository.findOneBy({
id: userId,
host: IsNull(),
isSuspended: false,
});
return await this.userInfo(request, reply, user);
});
fastify.get<{ Params: { user: string; } }>('/@:user', { constraints: { apOrHtml: 'ap' } }, async (request, reply) => {
fastify.get<{ Params: { acct: string; } }>('/@:acct', { constraints: { apOrHtml: 'ap' } }, async (request, reply) => {
vary(reply.raw, 'Accept');
const spritedAcct = request.params.acct.toLowerCase().split('@');
//@foo@bar@baz なんてないはず
if (spritedAcct.length > 2) {
reply.code(400);
}
console.log(spritedAcct);
const user = await this.usersRepository.findOneBy({
usernameLower: request.params.user.toLowerCase(),
host: IsNull(),
usernameLower: spritedAcct[0],
host: spritedAcct[1] ?? IsNull(),
isSuspended: false,
});