diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-26 15:04:37 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-26 15:04:37 +0200 |
commit | 15a7eafb892441957ba7dd6fcbf556086fe5b2b3 (patch) | |
tree | 0786bd1a96c7d168a097ffcf5893737db2ab578e /server/models | |
parent | 9162fdd36300d2478f13d6ad346ec2c323f40faa (diff) | |
download | PeerTube-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.ts | 8 | ||||
-rw-r--r-- | server/models/video/video.ts | 7 |
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 { | |||
20 | import { setAsUpdated } from '@server/helpers/database-utils' | 20 | import { setAsUpdated } from '@server/helpers/database-utils' |
21 | import { buildUUID, uuidToShort } from '@server/helpers/uuid' | 21 | import { buildUUID, uuidToShort } from '@server/helpers/uuid' |
22 | import { MAccountId, MChannelId } from '@server/types/models' | 22 | import { MAccountId, MChannelId } from '@server/types/models' |
23 | import { AttributesOnly } from '@shared/core-utils' | 23 | import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistLink, buildPlaylistWatchPath } from '@shared/core-utils' |
24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
25 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' | 25 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' |
26 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 26 | import { 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' |
27 | import { setAsUpdated } from '@server/helpers/database-utils' | 27 | import { setAsUpdated } from '@server/helpers/database-utils' |
28 | import { buildNSFWFilter } from '@server/helpers/express-utils' | 28 | import { buildNSFWFilter } from '@server/helpers/express-utils' |
29 | import { shortToUUID } from '@server/helpers/uuid' | ||
29 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' | 30 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' |
30 | import { LiveManager } from '@server/lib/live/live-manager' | 31 | import { LiveManager } from '@server/lib/live/live-manager' |
31 | import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' | 32 | import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' |
32 | import { getServerActor } from '@server/models/application/application' | 33 | import { getServerActor } from '@server/models/application/application' |
33 | import { ModelCache } from '@server/models/model-cache' | 34 | import { ModelCache } from '@server/models/model-cache' |
34 | import { AttributesOnly } from '@shared/core-utils' | 35 | import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath } from '@shared/core-utils' |
35 | import { VideoFile } from '@shared/models/videos/video-file.model' | 36 | import { VideoFile } from '@shared/models/videos/video-file.model' |
36 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' | 37 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' |
37 | import { VideoObject } from '../../../shared/models/activitypub/objects' | 38 | import { 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 () { |