From 5ec89ea0c3674a3b0b34f73cd576ee011530c9f0 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 6 Jan 2023 22:34:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0?= =?UTF-8?q?=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=AB=E3=83=97=E3=83=AD=E3=82=AD?= =?UTF-8?q?=E3=82=B7=E3=82=92=E5=BE=A9=E6=B4=BB=20(#9481)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wip * Revert "Update ClientServerService.ts" This reverts commit 88c64ece78db199d2f4685180511f2d6b84945d6. * Revert "disable custom emoji proxy temporary" This reverts commit 495d513efdb8b2a996287fd54ae5014832352616. * :v: --- packages/backend/src/misc/is-mime-image.ts | 1 + .../src/server/MediaProxyServerService.ts | 21 +++++++++++++------ .../src/server/web/ClientServerService.ts | 5 ----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/misc/is-mime-image.ts b/packages/backend/src/misc/is-mime-image.ts index 168a9a7af6..acf5c1ede3 100644 --- a/packages/backend/src/misc/is-mime-image.ts +++ b/packages/backend/src/misc/is-mime-image.ts @@ -3,6 +3,7 @@ import { FILE_TYPE_BROWSERSAFE } from '@/const.js'; const dictionary = { 'safe-file': FILE_TYPE_BROWSERSAFE, 'sharp-convertible-image': ['image/jpeg', 'image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng', 'image/webp', 'image/avif', 'image/svg+xml'], + 'sharp-animation-convertible-image': ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/avif', 'image/svg+xml'], }; export const isMimeImage = (mime: string, type: keyof typeof dictionary): boolean => dictionary[type].includes(mime); diff --git a/packages/backend/src/server/MediaProxyServerService.ts b/packages/backend/src/server/MediaProxyServerService.ts index 4491a17545..5b76f15020 100644 --- a/packages/backend/src/server/MediaProxyServerService.ts +++ b/packages/backend/src/server/MediaProxyServerService.ts @@ -79,10 +79,18 @@ export class MediaProxyServerService { const { mime, ext } = await this.fileInfoService.detectType(path); const isConvertibleImage = isMimeImage(mime, 'sharp-convertible-image'); + const isAnimationConvertibleImage = isMimeImage(mime, 'sharp-animation-convertible-image'); let image: IImage; if ('emoji' in request.query && isConvertibleImage) { - const data = await sharp(path, { animated: !('static' in request.query) }) + if (!isAnimationConvertibleImage && !('static' in request.query)) { + image = { + data: fs.readFileSync(path), + ext, + type: mime, + }; + } else { + const data = await sharp(path, { animated: !('static' in request.query) }) .resize({ height: 128, withoutEnlargement: true, @@ -90,11 +98,12 @@ export class MediaProxyServerService { .webp(webpDefault) .toBuffer(); - image = { - data, - ext: 'webp', - type: 'image/webp', - }; + image = { + data, + ext: 'webp', + type: 'image/webp', + }; + } } else if ('static' in request.query && isConvertibleImage) { image = await this.imageProcessingService.convertToWebp(path, 498, 280); } else if ('preview' in request.query && isConvertibleImage) { diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 461d1d489b..263b15cc5e 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -251,10 +251,6 @@ export class ClientServerService { reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\''); - // || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ) - return await reply.redirect(301, emoji.publicUrl || emoji.originalUrl); - - /* https://github.com/misskey-dev/misskey/pull/9431#issuecomment-1373006446 const url = new URL('/proxy/emoji.webp', this.config.url); // || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ) url.searchParams.set('url', emoji.publicUrl || emoji.originalUrl); @@ -265,7 +261,6 @@ export class ClientServerService { 301, url.toString(), ); - */ }); fastify.get<{ Params: { path: string } }>('/fluent-emoji/:path(.*)', async (request, reply) => { From 0f3399753d4f06e37fdbe1dcfb3fe8f29bd0dc36 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 6 Jan 2023 14:00:54 +0000 Subject: [PATCH 2/2] chore: remove ` Search` from the name of OpenSearch --- packages/backend/src/server/web/ClientServerService.ts | 2 +- packages/backend/src/server/web/views/base.pug | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 461d1d489b..326d409953 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -362,7 +362,7 @@ export class ClientServerService { const name = meta.name || 'Misskey'; let content = ''; content += ''; - content += `${name} Search`; + content += `${name}`; content += `${name} Search`; content += 'UTF-8'; content += `${this.config.url}/favicon.ico`; diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug index b472cff899..b27bbcbce0 100644 --- a/packages/backend/src/server/web/views/base.pug +++ b/packages/backend/src/server/web/views/base.pug @@ -31,7 +31,7 @@ html link(rel='icon' href= icon || '/favicon.ico') link(rel='apple-touch-icon' href= icon || '/apple-touch-icon.png') link(rel='manifest' href='/manifest.json') - link(rel='search' type='application/opensearchdescription+xml' title=((title || "Misskey") + " Search") href=`${url}/opensearch.xml`) + link(rel='search' type='application/opensearchdescription+xml' title=(title || "Misskey") href=`${url}/opensearch.xml`) link(rel='prefetch' href='https://xn--931a.moe/assets/info.jpg') link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg') link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg')