From 54f789bd555adfc8ecdcabfbc9f88935e212014b Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 7 Feb 2023 13:53:18 +0000 Subject: [PATCH] =?UTF-8?q?fix(server):=20DriveFileEntityService.getPublic?= =?UTF-8?q?Url=E8=AA=BF=E6=95=B4=20-=20=E5=A4=96=E9=83=A8MediaProxy?= =?UTF-8?q?=E3=81=A7=E3=81=AF=E3=83=93=E3=83=87=E3=82=AA=E3=81=AE=E3=82=B5?= =?UTF-8?q?=E3=83=A0=E3=83=8D=E3=82=A4=E3=83=AB=E3=82=92=E7=94=9F=E6=88=90?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=81=AE=E3=81=A7=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E3=81=AB=E6=8A=95=E3=81=92=E3=81=AA=E3=81=84=20-=20th?= =?UTF-8?q?umbnailUrl=E3=81=8C=E5=AD=98=E5=9C=A8=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=A0=B4=E5=90=88=E3=80=81=E7=94=BB=E5=83=8F=E3=81=AE?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AF=E3=83=97=E3=83=AD=E3=82=AD=E3=82=B7?= =?UTF-8?q?=E3=81=A7=E5=9C=A7=E7=B8=AE=E3=81=95=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/entities/DriveFileEntityService.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/core/entities/DriveFileEntityService.ts b/packages/backend/src/core/entities/DriveFileEntityService.ts index efc196f74..9dd115d45 100644 --- a/packages/backend/src/core/entities/DriveFileEntityService.ts +++ b/packages/backend/src/core/entities/DriveFileEntityService.ts @@ -20,6 +20,7 @@ type PackOptions = { withUser?: boolean, }; import { bindThis } from '@/decorators.js'; +import { isMimeImage } from '@/misc/is-mime-image.js'; @Injectable() export class DriveFileEntityService { @@ -82,7 +83,9 @@ export class DriveFileEntityService { // リモートかつメディアプロキシ if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) { - return proxiedUrl(file.uri); + if (!(mode === 'static' && file.type.startsWith('video'))) { + return proxiedUrl(file.uri); + } } // リモートかつ期限切れはローカルプロキシを試みる @@ -91,20 +94,19 @@ export class DriveFileEntityService { if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外 const url = `${this.config.url}/files/${key}`; - if (mode === 'avatar') return proxiedUrl(url); + if (mode === 'avatar') return proxiedUrl(file.uri); return url; } } - const isImage = file.type && ['image/png', 'image/apng', 'image/gif', 'image/jpeg', 'image/webp', 'image/avif', 'image/svg+xml'].includes(file.type); - - if (mode === 'static') { - return file.thumbnailUrl ?? (isImage ? (file.webpublicUrl ?? file.url) : null); - } - const url = file.webpublicUrl ?? file.url; - if (mode === 'avatar') return proxiedUrl(url); + if (mode === 'static') { + return file.thumbnailUrl ?? (isMimeImage(file.type, 'sharp-convertible-image') ? proxiedUrl(url) : null); + } + if (mode === 'avatar') { + return proxiedUrl(url); + } return url; }