mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 21:13:09 +02: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,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue