aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-26 15:04:37 +0200
committerChocobozzz <me@florianbigard.com>2021-07-26 15:04:37 +0200
commit15a7eafb892441957ba7dd6fcbf556086fe5b2b3 (patch)
tree0786bd1a96c7d168a097ffcf5893737db2ab578e /server/models
parent9162fdd36300d2478f13d6ad346ec2c323f40faa (diff)
downloadPeerTube-15a7eafb892441957ba7dd6fcbf556086fe5b2b3.tar.gz
PeerTube-15a7eafb892441957ba7dd6fcbf556086fe5b2b3.tar.zst
PeerTube-15a7eafb892441957ba7dd6fcbf556086fe5b2b3.zip
Refactor video links builders
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-playlist.ts8
-rw-r--r--server/models/video/video.ts7
2 files changed, 8 insertions, 7 deletions
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index af81c9906..245475f94 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -20,7 +20,7 @@ import {
20import { setAsUpdated } from '@server/helpers/database-utils' 20import { setAsUpdated } from '@server/helpers/database-utils'
21import { buildUUID, uuidToShort } from '@server/helpers/uuid' 21import { buildUUID, uuidToShort } from '@server/helpers/uuid'
22import { MAccountId, MChannelId } from '@server/types/models' 22import { MAccountId, MChannelId } from '@server/types/models'
23import { AttributesOnly } from '@shared/core-utils' 23import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistLink, buildPlaylistWatchPath } from '@shared/core-utils'
24import { ActivityIconObject } from '../../../shared/models/activitypub/objects' 24import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
25import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' 25import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
@@ -560,12 +560,12 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli
560 return join(STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename) 560 return join(STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename)
561 } 561 }
562 562
563 getWatchUrl () { 563 getWatchStaticPath () {
564 return WEBSERVER.URL + '/w/p/' + this.uuid 564 return buildPlaylistWatchPath({ shortUUID: uuidToShort(this.uuid) })
565 } 565 }
566 566
567 getEmbedStaticPath () { 567 getEmbedStaticPath () {
568 return '/video-playlists/embed/' + this.uuid 568 return buildPlaylistEmbedPath(this)
569 } 569 }
570 570
571 static async getStats () { 571 static async getStats () {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 0f0f894e4..543e604bb 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -26,12 +26,13 @@ import {
26} from 'sequelize-typescript' 26} from 'sequelize-typescript'
27import { setAsUpdated } from '@server/helpers/database-utils' 27import { setAsUpdated } from '@server/helpers/database-utils'
28import { buildNSFWFilter } from '@server/helpers/express-utils' 28import { buildNSFWFilter } from '@server/helpers/express-utils'
29import { shortToUUID } from '@server/helpers/uuid'
29import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' 30import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
30import { LiveManager } from '@server/lib/live/live-manager' 31import { LiveManager } from '@server/lib/live/live-manager'
31import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' 32import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths'
32import { getServerActor } from '@server/models/application/application' 33import { getServerActor } from '@server/models/application/application'
33import { ModelCache } from '@server/models/model-cache' 34import { ModelCache } from '@server/models/model-cache'
34import { AttributesOnly } from '@shared/core-utils' 35import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath } from '@shared/core-utils'
35import { VideoFile } from '@shared/models/videos/video-file.model' 36import { VideoFile } from '@shared/models/videos/video-file.model'
36import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' 37import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'
37import { VideoObject } from '../../../shared/models/activitypub/objects' 38import { VideoObject } from '../../../shared/models/activitypub/objects'
@@ -1578,11 +1579,11 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1578 } 1579 }
1579 1580
1580 getWatchStaticPath () { 1581 getWatchStaticPath () {
1581 return '/w/' + this.uuid 1582 return buildVideoWatchPath({ shortUUID: shortToUUID(this.uuid) })
1582 } 1583 }
1583 1584
1584 getEmbedStaticPath () { 1585 getEmbedStaticPath () {
1585 return '/videos/embed/' + this.uuid 1586 return buildVideoEmbedPath(this)
1586 } 1587 }
1587 1588
1588 getMiniatureStaticPath () { 1589 getMiniatureStaticPath () {