summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/web/ClientServerService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-01-07 14:19:25 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-01-07 14:19:25 +0900
commit54e3fccd8763c1138af71ad129ed138e06765d84 (patch)
tree445d694566283afd4416d38e64592a4b99935b12 /packages/backend/src/server/web/ClientServerService.ts
parentfix chart rendering (diff)
downloadsharkey-54e3fccd8763c1138af71ad129ed138e06765d84.tar.gz
sharkey-54e3fccd8763c1138af71ad129ed138e06765d84.tar.bz2
sharkey-54e3fccd8763c1138af71ad129ed138e06765d84.zip
enhance(server): refactor and tweak emoji proxy
Diffstat (limited to 'packages/backend/src/server/web/ClientServerService.ts')
-rw-r--r--packages/backend/src/server/web/ClientServerService.ts42
1 files changed, 0 insertions, 42 deletions
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index a7701e1b24..c69975fd79 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -1,6 +1,5 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
-import { PathOrFileDescriptor, readFileSync } from 'node:fs';
import { Inject, Injectable } from '@nestjs/common';
import { createBullBoard } from '@bull-board/api';
import { BullAdapter } from '@bull-board/api/bullAdapter.js';
@@ -71,9 +70,6 @@ export class ClientServerService {
@Inject(DI.pagesRepository)
private pagesRepository: PagesRepository,
- @Inject(DI.emojisRepository)
- private emojisRepository: EmojisRepository,
-
@Inject(DI.flashsRepository)
private flashsRepository: FlashsRepository,
@@ -225,44 +221,6 @@ export class ClientServerService {
return reply.sendFile('/apple-touch-icon.png', staticAssets);
});
- 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$/)) {
- reply.code(404);
- return;
- }
-
- reply.header('Cache-Control', 'public, max-age=86400');
-
- const name = path.split('@')[0].replace('.webp', '');
- const host = path.split('@')[1]?.replace('.webp', '');
-
- const emoji = await this.emojisRepository.findOneBy({
- // `@.` is the spec of ReactionService.decodeReaction
- host: (host == null || host === '.') ? IsNull() : host,
- name: name,
- });
-
- if (emoji == null) {
- reply.code(404);
- return;
- }
-
- reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\'');
-
- const url = new URL('/proxy/emoji.webp', this.config.url);
- // || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
- url.searchParams.set('url', emoji.publicUrl || 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) => {
const path = request.params.path;