aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-28 17:30:59 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-06-29 14:56:35 +0200
commitd4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb (patch)
treea4cb07318100031951c3dffc61f4f2cb95d2cbd0 /client/src/app/shared
parent62ddc31a9e4b92d7d27898ccfc363f68ab044139 (diff)
downloadPeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.tar.gz
PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.tar.zst
PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.zip
Support short uuid for GET video/playlist
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts4
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.ts2
-rw-r--r--client/src/app/shared/shared-main/users/user-notification.model.ts3
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts15
-rw-r--r--client/src/app/shared/shared-share-modal/video-share.component.ts7
-rw-r--r--client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts4
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.model.ts4
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.service.ts7
-rw-r--r--client/src/app/shared/shared-video-miniature/video-miniature.component.ts4
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts2
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts2
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist.model.ts8
12 files changed, 42 insertions, 20 deletions
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
index 07b9dddba..67aa0e399 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
@@ -116,11 +116,11 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
116 } 116 }
117 117
118 getVideoUrl (abuse: AdminAbuse) { 118 getVideoUrl (abuse: AdminAbuse) {
119 return Video.buildClientUrl(abuse.video.uuid) 119 return Video.buildWatchUrl(abuse.video)
120 } 120 }
121 121
122 getCommentUrl (abuse: AdminAbuse) { 122 getCommentUrl (abuse: AdminAbuse) {
123 return Video.buildClientUrl(abuse.comment.video.uuid) + ';threadId=' + abuse.comment.threadId 123 return Video.buildWatchUrl(abuse.comment.video) + ';threadId=' + abuse.comment.threadId
124 } 124 }
125 125
126 getAccountUrl (abuse: ProcessedAbuse) { 126 getAccountUrl (abuse: ProcessedAbuse) {
diff --git a/client/src/app/shared/shared-main/angular/link.component.ts b/client/src/app/shared/shared-main/angular/link.component.ts
index 76d1201b9..597a16871 100644
--- a/client/src/app/shared/shared-main/angular/link.component.ts
+++ b/client/src/app/shared/shared-main/angular/link.component.ts
@@ -6,7 +6,7 @@ import { Component, Input, ViewEncapsulation } from '@angular/core'
6 templateUrl: './link.component.html' 6 templateUrl: './link.component.html'
7}) 7})
8export class LinkComponent { 8export class LinkComponent {
9 @Input() internalLink?: any[] 9 @Input() internalLink?: string | any[]
10 10
11 @Input() href?: string 11 @Input() href?: string
12 @Input() target?: string 12 @Input() target?: string
diff --git a/client/src/app/shared/shared-main/users/user-notification.model.ts b/client/src/app/shared/shared-main/users/user-notification.model.ts
index c80bc13b0..4c15eb981 100644
--- a/client/src/app/shared/shared-main/users/user-notification.model.ts
+++ b/client/src/app/shared/shared-main/users/user-notification.model.ts
@@ -12,6 +12,7 @@ import {
12 UserRight, 12 UserRight,
13 VideoInfo 13 VideoInfo
14} from '@shared/models' 14} from '@shared/models'
15import { Video } from '../video'
15 16
16export class UserNotification implements UserNotificationServer { 17export class UserNotification implements UserNotificationServer {
17 id: number 18 id: number
@@ -238,7 +239,7 @@ export class UserNotification implements UserNotificationServer {
238 } 239 }
239 240
240 private buildVideoUrl (video: { uuid: string }) { 241 private buildVideoUrl (video: { uuid: string }) {
241 return '/w/' + video.uuid 242 return Video.buildWatchUrl(video)
242 } 243 }
243 244
244 private buildAccountUrl (account: { name: string, host: string }) { 245 private buildAccountUrl (account: { name: string, host: string }) {
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index ab8ed9051..f0a4a3f37 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -26,12 +26,18 @@ export class Video implements VideoServerModel {
26 licence: VideoConstant<number> 26 licence: VideoConstant<number>
27 language: VideoConstant<string> 27 language: VideoConstant<string>
28 privacy: VideoConstant<VideoPrivacy> 28 privacy: VideoConstant<VideoPrivacy>
29
29 description: string 30 description: string
31
30 duration: number 32 duration: number
31 durationLabel: string 33 durationLabel: string
34
32 id: number 35 id: number
33 uuid: string 36 uuid: string
37 shortUUID: string
38
34 isLocal: boolean 39 isLocal: boolean
40
35 name: string 41 name: string
36 serverHost: string 42 serverHost: string
37 thumbnailPath: string 43 thumbnailPath: string
@@ -85,8 +91,12 @@ export class Video implements VideoServerModel {
85 91
86 pluginData?: any 92 pluginData?: any
87 93
88 static buildClientUrl (videoUUID: string) { 94 static buildWatchUrl (video: Partial<Pick<Video, 'uuid' | 'shortUUID'>>) {
89 return '/w/' + videoUUID 95 return '/w/' + (video.shortUUID || video.uuid)
96 }
97
98 static buildUpdateUrl (video: Pick<Video, 'uuid'>) {
99 return '/videos/update/' + video.uuid
90 } 100 }
91 101
92 constructor (hash: VideoServerModel, translations = {}) { 102 constructor (hash: VideoServerModel, translations = {}) {
@@ -109,6 +119,7 @@ export class Video implements VideoServerModel {
109 119
110 this.id = hash.id 120 this.id = hash.id
111 this.uuid = hash.uuid 121 this.uuid = hash.uuid
122 this.shortUUID = hash.shortUUID
112 123
113 this.isLocal = hash.isLocal 124 this.isLocal = hash.isLocal
114 this.name = hash.name 125 this.name = hash.name
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts
index 2a73e6166..a41ff248b 100644
--- a/client/src/app/shared/shared-share-modal/video-share.component.ts
+++ b/client/src/app/shared/shared-share-modal/video-share.component.ts
@@ -1,5 +1,5 @@
1import { Component, ElementRef, Input, ViewChild } from '@angular/core' 1import { Component, ElementRef, Input, ViewChild } from '@angular/core'
2import { VideoDetails } from '@app/shared/shared-main' 2import { Video, VideoDetails } from '@app/shared/shared-main'
3import { VideoPlaylist } from '@app/shared/shared-video-playlist' 3import { VideoPlaylist } from '@app/shared/shared-video-playlist'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { VideoCaption } from '@shared/models' 5import { VideoCaption } from '@shared/models'
@@ -98,14 +98,15 @@ export class VideoShareComponent {
98 98
99 getVideoUrl () { 99 getVideoUrl () {
100 let baseUrl = this.customizations.originUrl ? this.video.originInstanceUrl : window.location.origin 100 let baseUrl = this.customizations.originUrl ? this.video.originInstanceUrl : window.location.origin
101 baseUrl += '/w/' + this.video.uuid 101 baseUrl += Video.buildWatchUrl(this.video)
102
102 const options = this.getVideoOptions(baseUrl) 103 const options = this.getVideoOptions(baseUrl)
103 104
104 return buildVideoLink(options) 105 return buildVideoLink(options)
105 } 106 }
106 107
107 getPlaylistUrl () { 108 getPlaylistUrl () {
108 const base = window.location.origin + '/w/p/' + this.playlist.uuid 109 const base = window.location.origin + VideoPlaylist.buildWatchUrl(this.playlist)
109 110
110 if (!this.includeVideoInPlaylist) return base 111 if (!this.includeVideoInPlaylist) return base
111 112
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
index d5583c29f..ad5d30db2 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
@@ -12,7 +12,7 @@ export class VideoThumbnailComponent {
12 @Input() video: Video 12 @Input() video: Video
13 @Input() nsfw = false 13 @Input() nsfw = false
14 14
15 @Input() videoRouterLink: any[] 15 @Input() videoRouterLink: string | any[]
16 @Input() queryParams: { [ p: string ]: any } 16 @Input() queryParams: { [ p: string ]: any }
17 @Input() videoHref: string 17 @Input() videoHref: string
18 @Input() videoTarget: string 18 @Input() videoTarget: string
@@ -57,7 +57,7 @@ export class VideoThumbnailComponent {
57 getVideoRouterLink () { 57 getVideoRouterLink () {
58 if (this.videoRouterLink) return this.videoRouterLink 58 if (this.videoRouterLink) return this.videoRouterLink
59 59
60 return [ '/w', this.video.uuid ] 60 return Video.buildWatchUrl(this.video)
61 } 61 }
62 62
63 onWatchLaterClick (event: Event) { 63 onWatchLaterClick (event: Event) {
diff --git a/client/src/app/shared/shared-video-comment/video-comment.model.ts b/client/src/app/shared/shared-video-comment/video-comment.model.ts
index 94d6c5fa8..ba0f57e8f 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.model.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.model.ts
@@ -1,5 +1,5 @@
1import { getAbsoluteAPIUrl } from '@app/helpers' 1import { getAbsoluteAPIUrl } from '@app/helpers'
2import { Account, Actor } from '@app/shared/shared-main' 2import { Account, Actor, Video } from '@app/shared/shared-main'
3import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models' 3import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models'
4 4
5export class VideoComment implements VideoCommentServerModel { 5export class VideoComment implements VideoCommentServerModel {
@@ -85,7 +85,7 @@ export class VideoCommentAdmin implements VideoCommentAdminServerModel {
85 id: hash.video.id, 85 id: hash.video.id,
86 uuid: hash.video.uuid, 86 uuid: hash.video.uuid,
87 name: hash.video.name, 87 name: hash.video.name,
88 localUrl: '/w/' + hash.video.uuid 88 localUrl: Video.buildWatchUrl(hash.video)
89 } 89 }
90 90
91 this.localUrl = this.video.localUrl + ';threadId=' + this.threadId 91 this.localUrl = this.video.localUrl + ';threadId=' + this.threadId
diff --git a/client/src/app/shared/shared-video-comment/video-comment.service.ts b/client/src/app/shared/shared-video-comment/video-comment.service.ts
index c5aeb3c12..4f1452116 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.service.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.service.ts
@@ -9,6 +9,7 @@ import {
9 FeedFormat, 9 FeedFormat,
10 ResultList, 10 ResultList,
11 ThreadsResultList, 11 ThreadsResultList,
12 Video,
12 VideoComment as VideoCommentServerModel, 13 VideoComment as VideoCommentServerModel,
13 VideoCommentAdmin, 14 VideoCommentAdmin,
14 VideoCommentCreate, 15 VideoCommentCreate,
@@ -127,7 +128,7 @@ export class VideoCommentService {
127 ) 128 )
128 } 129 }
129 130
130 getVideoCommentsFeeds (videoUUID?: string) { 131 getVideoCommentsFeeds (video: Pick<Video, 'uuid'>) {
131 const feeds = [ 132 const feeds = [
132 { 133 {
133 format: FeedFormat.RSS, 134 format: FeedFormat.RSS,
@@ -146,9 +147,9 @@ export class VideoCommentService {
146 } 147 }
147 ] 148 ]
148 149
149 if (videoUUID !== undefined) { 150 if (video !== undefined) {
150 for (const feed of feeds) { 151 for (const feed of feeds) {
151 feed.url += '?videoId=' + videoUUID 152 feed.url += '?videoId=' + video.uuid
152 } 153 }
153 } 154 }
154 155
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index fe161c977..67e0de6a2 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -85,7 +85,7 @@ export class VideoMiniatureComponent implements OnInit {
85 playlistElementId?: number 85 playlistElementId?: number
86 } 86 }
87 87
88 videoRouterLink: any[] = [] 88 videoRouterLink: string | any[] = []
89 videoHref: string 89 videoHref: string
90 videoTarget: string 90 videoTarget: string
91 91
@@ -120,7 +120,7 @@ export class VideoMiniatureComponent implements OnInit {
120 120
121 buildVideoLink () { 121 buildVideoLink () {
122 if (this.videoLinkType === 'internal' || !this.video.url) { 122 if (this.videoLinkType === 'internal' || !this.video.url) {
123 this.videoRouterLink = [ '/w', this.video.uuid ] 123 this.videoRouterLink = Video.buildWatchUrl(this.video)
124 return 124 return
125 } 125 }
126 126
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts
index 57eab4dfd..d99170e4e 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts
@@ -66,7 +66,7 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit {
66 buildRouterLink () { 66 buildRouterLink () {
67 if (!this.playlist) return null 67 if (!this.playlist) return null
68 68
69 return [ '/w/p', this.playlist.uuid ] 69 return VideoPlaylist.buildWatchUrl(this.playlist)
70 } 70 }
71 71
72 buildRouterQuery () { 72 buildRouterQuery () {
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
index 8de5092a9..c80ea2e6b 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
@@ -39,7 +39,7 @@ export class VideoPlaylistMiniatureComponent implements OnInit {
39 } 39 }
40 40
41 if (this.linkType === 'internal' || !this.playlist.url) { 41 if (this.linkType === 'internal' || !this.playlist.url) {
42 this.routerLink = [ '/w/p', this.playlist.uuid ] 42 this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist)
43 return 43 return
44 } 44 }
45 45
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
index d67f372f4..d96b70922 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
@@ -13,6 +13,8 @@ import {
13export class VideoPlaylist implements ServerVideoPlaylist { 13export class VideoPlaylist implements ServerVideoPlaylist {
14 id: number 14 id: number
15 uuid: string 15 uuid: string
16 shortUUID: string
17
16 isLocal: boolean 18 isLocal: boolean
17 19
18 url: string 20 url: string
@@ -41,11 +43,17 @@ export class VideoPlaylist implements ServerVideoPlaylist {
41 43
42 videoChannelBy?: string 44 videoChannelBy?: string
43 45
46 static buildWatchUrl (playlist: Pick<VideoPlaylist, 'uuid' | 'shortUUID'>) {
47 return '/w/p/' + (playlist.uuid || playlist.shortUUID)
48 }
49
44 constructor (hash: ServerVideoPlaylist, translations: {}) { 50 constructor (hash: ServerVideoPlaylist, translations: {}) {
45 const absoluteAPIUrl = getAbsoluteAPIUrl() 51 const absoluteAPIUrl = getAbsoluteAPIUrl()
46 52
47 this.id = hash.id 53 this.id = hash.id
48 this.uuid = hash.uuid 54 this.uuid = hash.uuid
55 this.shortUUID = hash.shortUUID
56
49 this.url = hash.url 57 this.url = hash.url
50 this.isLocal = hash.isLocal 58 this.isLocal = hash.isLocal
51 59