From ca6d36227a9273f616a462d3aad6a721ab5dd627 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Jan 2020 11:53:38 +0100 Subject: Add url field in caption and use it for thumbnails --- server/models/video/thumbnail.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server/models/video/thumbnail.ts') diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts index 3b011b1d2..b69bc0872 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', @@ -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 () { -- cgit v1.2.3