summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-01-02 02:45:05 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-01-02 02:45:05 +0900
commit78ef0a9929a1a4460acdca4f1810f8c0ca08f37f (patch)
treebc4f5c22fcebab69de20ce097f92f1625e2c62a2 /src/models
parent期限切れ/未保存リモートファイルのローカルプロキシ (#5... (diff)
downloadsharkey-78ef0a9929a1a4460acdca4f1810f8c0ca08f37f.tar.gz
sharkey-78ef0a9929a1a4460acdca4f1810f8c0ca08f37f.tar.bz2
sharkey-78ef0a9929a1a4460acdca4f1810f8c0ca08f37f.zip
ドライブファイルURL生成などの修正 (#5671)
* Fix: リモートプロキシ時にサムネイルのContent-Typeがおかしい * fix drive
Diffstat (limited to 'src/models')
-rw-r--r--src/models/repositories/drive-file.ts20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/models/repositories/drive-file.ts b/src/models/repositories/drive-file.ts
index 5e3c1e94b8..63b9f60965 100644
--- a/src/models/repositories/drive-file.ts
+++ b/src/models/repositories/drive-file.ts
@@ -39,25 +39,13 @@ export class DriveFileRepository extends Repository<DriveFile> {
const key = thumbnail ? file.thumbnailAccessKey : file.webpublicAccessKey;
if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外
- let ext = '';
-
- if (file.name) {
- [ext] = (file.name.match(/\.(\w+)$/) || ['']);
- }
-
- if (ext === '') {
- if (file.type === 'image/jpeg') ext = '.jpg';
- if (file.type === 'image/png') ext = '.png';
- if (file.type === 'image/webp') ext = '.webp';
- if (file.type === 'image/apng') ext = '.apng';
- if (file.type === 'image/vnd.mozilla.apng') ext = '.apng';
- }
-
- return `/files/${key}/${key}${ext}`;
+ return `/files/${key}`;
}
}
- return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url);
+ const isImage = file.type && ['image/png', 'image/apng', 'image/gif', 'image/jpeg', 'image/webp', 'image/svg+xml'].includes(file.type);
+
+ return thumbnail ? (file.thumbnailUrl || (isImage ? (file.webpublicUrl || file.url) : null)) : (file.webpublicUrl || file.url);
}
public async clacDriveUsageOf(user: User['id'] | User): Promise<number> {