mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-11-24 15:06:48 +01:00
fix(server): DriveFileEntityService.getPublicUrl調整
- 外部MediaProxyではビデオのサムネイルを生成できないので外部に投げない - thumbnailUrlが存在しない場合、画像の場合はプロキシで圧縮させる
This commit is contained in:
parent
5ac9d13516
commit
54f789bd55
1 changed files with 11 additions and 9 deletions
|
@ -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,8 +83,10 @@ export class DriveFileEntityService {
|
|||
|
||||
// リモートかつメディアプロキシ
|
||||
if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) {
|
||||
if (!(mode === 'static' && file.type.startsWith('video'))) {
|
||||
return proxiedUrl(file.uri);
|
||||
}
|
||||
}
|
||||
|
||||
// リモートかつ期限切れはローカルプロキシを試みる
|
||||
if (file.uri != null && file.isLink && this.config.proxyRemoteFiles) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue