diff options
| author | 和風ドレッシング <37681609+CookieRamen@users.noreply.github.com> | 2019-12-20 01:54:28 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-12-20 01:54:28 +0900 |
| commit | 9bc07c1a1ce8c82c7f0d00a78a00f9c6e6a22b1f (patch) | |
| tree | 39bbcf7cc4e6ac9d5e7048de5fd9ba059e2792a5 /src/models | |
| parent | /files/ 下のヘッダ設定タイミングを修正 (#5650) (diff) | |
| download | sharkey-9bc07c1a1ce8c82c7f0d00a78a00f9c6e6a22b1f.tar.gz sharkey-9bc07c1a1ce8c82c7f0d00a78a00f9c6e6a22b1f.tar.bz2 sharkey-9bc07c1a1ce8c82c7f0d00a78a00f9c6e6a22b1f.zip | |
Media Proxy を実装 (#5649)
* Media Proxy を実装
* サンプルを追加
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/repositories/drive-file.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/models/repositories/drive-file.ts b/src/models/repositories/drive-file.ts index 702f195e9d..a20d393044 100644 --- a/src/models/repositories/drive-file.ts +++ b/src/models/repositories/drive-file.ts @@ -6,6 +6,7 @@ import { toPuny } from '../../misc/convert-host'; import { ensure } from '../../prelude/ensure'; import { awaitAll } from '../../prelude/await-all'; import { SchemaType } from '../../misc/schema'; +import config from '../../config'; export type PackedDriveFile = SchemaType<typeof packedDriveFileSchema>; @@ -22,7 +23,11 @@ export class DriveFileRepository extends Repository<DriveFile> { } public getPublicUrl(file: DriveFile, thumbnail = false): string | null { - return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url); + let url = thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url); + if (file.src !== null && file.userHost !== null && config.mediaProxy !== null) { + url = `${config.mediaProxy}/${thumbnail ? 'thumbnail' : ''}?url=${file.src}`; + } + return url; } public async clacDriveUsageOf(user: User['id'] | User): Promise<number> { |