diff --git a/CHANGELOG_YOJO.md b/CHANGELOG_YOJO.md index e3acb962dd..af943b1e3f 100644 --- a/CHANGELOG_YOJO.md +++ b/CHANGELOG_YOJO.md @@ -1,3 +1,8 @@ +## 1.2.0 + +### Server +- Enhance: `/users/${id}`に`Accept: application/ld+json`ではないリクエストが来たとき`/@${username}`にリダイレクトするように [#554](https://github.com/yojo-art/cherrypick/pull/554) + ## 1.1.0 Cherrypick 4.11.1 diff --git a/packages/backend/src/server/ActivityPubServerService.ts b/packages/backend/src/server/ActivityPubServerService.ts index 365207b34d..cb915faf88 100644 --- a/packages/backend/src/server/ActivityPubServerService.ts +++ b/packages/backend/src/server/ActivityPubServerService.ts @@ -667,6 +667,20 @@ export class ActivityPubServerService { return await this.userInfo(request, reply, user); }); + fastify.get<{ Params: { user: string; } }>('/users/:user', { constraints: { apOrHtml: 'html' } }, async (request, reply) => { + vary(reply.raw, 'Accept'); + + const userId = request.params.user; + + const user = await this.usersRepository.findOneBy({ + id: userId, + host: IsNull(), + isSuspended: false, + }); + if (user) reply.redirect(`/@${user.username}`); + reply.code(404); + }); + fastify.get<{ Params: { user: string; } }>('/@:user', { constraints: { apOrHtml: 'ap' } }, async (request, reply) => { vary(reply.raw, 'Accept');