Skip to content

Commit

Permalink
acctのリクエストはuserIdへリダイレクトするように
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaina committed Feb 20, 2022
1 parent db6acc9 commit 105e6d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/backend/src/server/proxy/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ export async function proxyAvatar(ctx: Koa.Context) {
return ctx.redirect('/static-assets/user-unknown.png');
}
if (!user.avatarUrl) return ctx.redirect(Users.getIdenticonUrl(user));
if (ctx.query.url !== user.avatarUrl) {
if (ctx.query.acct || ctx.query.url !== user.avatarUrl) {
// 最新の、キャッシュすべきURLへリダイレクト
logger.info(`redirect`);
const url = new URL(ctx.URL);
url.searchParams.set('url', user.avatarUrl);
if (ctx.query.acct) {
url.searchParams.delete('acct');
url.searchParams.set('userId', user.id);
}
return ctx.redirect(url.toString());
}

Expand Down

0 comments on commit 105e6d0

Please sign in to comment.