X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fthumbnail.ts;h=e396784d29124f7f43af55c855c561b5d9506ce2;hb=3d527ba173a37bd61ec8ad742642bb320d12995c;hp=3b011b1d285de4fb1caf5e44f4f5a2a020b377ed;hpb=d5692d4088cdd9fde3be6ff34be8ce2816dab0cf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts index 3b011b1d2..e396784d2 100644 --- a/server/models/video/thumbnail.ts +++ b/server/models/video/thumbnail.ts @@ -19,6 +19,8 @@ import { CONFIG } from '../../initializers/config' import { VideoModel } from './video' import { VideoPlaylistModel } from './video-playlist' import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' +import { MVideoAccountLight } from '@server/typings/models' +import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' @Table({ tableName: 'thumbnail', @@ -90,7 +92,7 @@ export class ThumbnailModel extends Model { @UpdatedAt updatedAt: Date - private static types: { [ id in ThumbnailType ]: { label: string, directory: string, staticPath: string } } = { + private static readonly types: { [ id in ThumbnailType ]: { label: string, directory: string, staticPath: string } } = { [ThumbnailType.MINIATURE]: { label: 'miniature', directory: CONFIG.STORAGE.THUMBNAILS_DIR, @@ -126,11 +128,14 @@ export class ThumbnailModel extends Model { return videoUUID + '.jpg' } - getFileUrl (isLocal: boolean) { - if (isLocal === false) return this.fileUrl + getFileUrl (video: MVideoAccountLight) { + const staticPath = ThumbnailModel.types[this.type].staticPath + this.filename - const staticPath = ThumbnailModel.types[this.type].staticPath - return WEBSERVER.URL + staticPath + this.filename + if (video.isOwned()) return WEBSERVER.URL + staticPath + if (this.fileUrl) return this.fileUrl + + // Fallback if we don't have a file URL + return buildRemoteVideoBaseUrl(video, staticPath) } getPath () {