Skip to content

Commit

Permalink
Enhance: /users/${id}Accept: application/ld+jsonではないリクエストが来たとき`/…
Browse files Browse the repository at this point in the history
…@${username}`にリダイレクトするように (#554)
  • Loading branch information
penginn-net authored Nov 28, 2024
1 parent ea225d0 commit a037a66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG_YOJO.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 14 additions & 0 deletions packages/backend/src/server/ActivityPubServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit a037a66

Please sign in to comment.