import { VideoModel } from './video'
import { VideoPlaylistModel } from './video-playlist'
import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type'
+import { MVideoAccountLight } from '@server/types/models'
+import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
@Table({
tableName: 'thumbnail',
@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,
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 () {