diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-28 17:30:59 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-29 14:56:35 +0200 |
commit | d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb (patch) | |
tree | a4cb07318100031951c3dffc61f4f2cb95d2cbd0 /server/models/video | |
parent | 62ddc31a9e4b92d7d27898ccfc363f68ab044139 (diff) | |
download | PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.tar.gz PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.tar.zst PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.zip |
Support short uuid for GET video/playlist
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/formatter/video-format-utils.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-caption.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts index 8880c0450..672c671b8 100644 --- a/server/models/video/formatter/video-format-utils.ts +++ b/server/models/video/formatter/video-format-utils.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { uuidToShort } from '@server/helpers/uuid' | ||
1 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 2 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
2 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-paths' | 3 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-paths' |
3 | import { VideoFile } from '@shared/models/videos/video-file.model' | 4 | import { VideoFile } from '@shared/models/videos/video-file.model' |
@@ -47,6 +48,8 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFor | |||
47 | const videoObject: Video = { | 48 | const videoObject: Video = { |
48 | id: video.id, | 49 | id: video.id, |
49 | uuid: video.uuid, | 50 | uuid: video.uuid, |
51 | shortUUID: uuidToShort(video.uuid), | ||
52 | |||
50 | name: video.name, | 53 | name: video.name, |
51 | category: { | 54 | category: { |
52 | id: video.category, | 55 | id: video.category, |
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index 5ec944b9e..d24be56c3 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | Table, | 15 | Table, |
16 | UpdatedAt | 16 | UpdatedAt |
17 | } from 'sequelize-typescript' | 17 | } from 'sequelize-typescript' |
18 | import { v4 as uuidv4 } from 'uuid' | 18 | import { buildUUID } from '@server/helpers/uuid' |
19 | import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' | 19 | import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' |
20 | import { AttributesOnly } from '@shared/core-utils' | 20 | import { AttributesOnly } from '@shared/core-utils' |
21 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' | 21 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' |
@@ -182,7 +182,7 @@ export class VideoCaptionModel extends Model<Partial<AttributesOnly<VideoCaption | |||
182 | } | 182 | } |
183 | 183 | ||
184 | static generateCaptionName (language: string) { | 184 | static generateCaptionName (language: string) { |
185 | return `${uuidv4()}-${language}.vtt` | 185 | return `${buildUUID()}-${language}.vtt` |
186 | } | 186 | } |
187 | 187 | ||
188 | isOwned () { | 188 | isOwned () { |
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 7aa6b6c6e..af81c9906 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -17,8 +17,8 @@ import { | |||
17 | Table, | 17 | Table, |
18 | UpdatedAt | 18 | UpdatedAt |
19 | } from 'sequelize-typescript' | 19 | } from 'sequelize-typescript' |
20 | import { v4 as uuidv4 } from 'uuid' | ||
21 | import { setAsUpdated } from '@server/helpers/database-utils' | 20 | import { setAsUpdated } from '@server/helpers/database-utils' |
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 } from '@shared/core-utils' |
24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 24 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
@@ -545,7 +545,7 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli | |||
545 | generateThumbnailName () { | 545 | generateThumbnailName () { |
546 | const extension = '.jpg' | 546 | const extension = '.jpg' |
547 | 547 | ||
548 | return 'playlist-' + uuidv4() + extension | 548 | return 'playlist-' + buildUUID() + extension |
549 | } | 549 | } |
550 | 550 | ||
551 | getThumbnailUrl () { | 551 | getThumbnailUrl () { |
@@ -617,6 +617,8 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli | |||
617 | return { | 617 | return { |
618 | id: this.id, | 618 | id: this.id, |
619 | uuid: this.uuid, | 619 | uuid: this.uuid, |
620 | shortUUID: uuidToShort(this.uuid), | ||
621 | |||
620 | isLocal: this.isOwned(), | 622 | isLocal: this.isOwned(), |
621 | 623 | ||
622 | url: this.url, | 624 | url: this.url, |