summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/web/ClientServerService.ts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2022-12-30 12:00:50 +0900
committerGitHub <noreply@github.com>2022-12-30 12:00:50 +0900
commit8b46edeccf5a8907afbb871e3eb5b3b8eef967a8 (patch)
tree1411e540282c4b0d2365d3a2c7e01902a3403a3a /packages/backend/src/server/web/ClientServerService.ts
parentfix(client): fix position calculation of nested context menu (diff)
downloadsharkey-8b46edeccf5a8907afbb871e3eb5b3b8eef967a8.tar.gz
sharkey-8b46edeccf5a8907afbb871e3eb5b3b8eef967a8.tar.bz2
sharkey-8b46edeccf5a8907afbb871e3eb5b3b8eef967a8.zip
enhance: Proxy custom emojis to reduce image size and accelerate the frontend (#9431)
* fix(server): /emoji to accept `@.` host expression * fix(client): use MkEmoji for custom emoji in MkEmojiPicker * change convertToWebp * nanka iroiro * remove * fix * nearLosslessは労多くして益少なしなのでやめる * do not cleanup tmp for development * update sharp.js to 0.31.3 * mixed: true * fix MkAutocomplete of 912791b3ab * clean up * https://github.com/misskey-dev/misskey/pull/9431#discussion_r1059215943
Diffstat (limited to 'packages/backend/src/server/web/ClientServerService.ts')
-rw-r--r--packages/backend/src/server/web/ClientServerService.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index 84e8481d55..83a30dbe0b 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -220,7 +220,7 @@ export class ClientServerService {
return reply.sendFile('/apple-touch-icon.png', staticAssets);
});
- fastify.get<{ Params: { path: string } }>('/emoji/:path(.*)', async (request, reply) => {
+ fastify.get<{ Params: { path: string }; Querystring: { static?: any; }; }>('/emoji/:path(.*)', async (request, reply) => {
const path = request.params.path;
if (!path.match(/^[a-zA-Z0-9\-_@\.]+?\.webp$/)) {
@@ -244,8 +244,15 @@ export class ClientServerService {
reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\'');
- // ?? emoji.originalUrl してるのは後方互換性のため
- return await reply.redirect(301, emoji.publicUrl ?? emoji.originalUrl);
+ const url = new URL("/proxy/emoji.webp", this.config.url);
+ url.searchParams.set('url', emoji.publicUrl ?? emoji.originalUrl); // ?? emoji.originalUrl してるのは後方互換性のため
+ url.searchParams.set('emoji', '1');
+ if ('static' in request.query) url.searchParams.set('static', '1');
+
+ return await reply.redirect(
+ 301,
+ url.toString(),
+ );
});
fastify.get<{ Params: { path: string } }>('/fluent-emoji/:path(.*)', async (request, reply) => {