From d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Jun 2021 17:30:59 +0200 Subject: Support short uuid for GET video/playlist --- .../shared-abuse-list/abuse-list-table.component.ts | 4 ++-- .../src/app/shared/shared-main/angular/link.component.ts | 2 +- .../shared/shared-main/users/user-notification.model.ts | 3 ++- client/src/app/shared/shared-main/video/video.model.ts | 15 +++++++++++++-- .../shared/shared-share-modal/video-share.component.ts | 7 ++++--- .../shared/shared-thumbnail/video-thumbnail.component.ts | 4 ++-- .../shared/shared-video-comment/video-comment.model.ts | 4 ++-- .../shared/shared-video-comment/video-comment.service.ts | 7 ++++--- .../shared-video-miniature/video-miniature.component.ts | 4 ++-- .../video-playlist-element-miniature.component.ts | 2 +- .../video-playlist-miniature.component.ts | 2 +- .../shared/shared-video-playlist/video-playlist.model.ts | 8 ++++++++ 12 files changed, 42 insertions(+), 20 deletions(-) (limited to 'client/src/app/shared') 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 { } getVideoUrl (abuse: AdminAbuse) { - return Video.buildClientUrl(abuse.video.uuid) + return Video.buildWatchUrl(abuse.video) } getCommentUrl (abuse: AdminAbuse) { - return Video.buildClientUrl(abuse.comment.video.uuid) + ';threadId=' + abuse.comment.threadId + return Video.buildWatchUrl(abuse.comment.video) + ';threadId=' + abuse.comment.threadId } 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' templateUrl: './link.component.html' }) export class LinkComponent { - @Input() internalLink?: any[] + @Input() internalLink?: string | any[] @Input() href?: string @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 { UserRight, VideoInfo } from '@shared/models' +import { Video } from '../video' export class UserNotification implements UserNotificationServer { id: number @@ -238,7 +239,7 @@ export class UserNotification implements UserNotificationServer { } private buildVideoUrl (video: { uuid: string }) { - return '/w/' + video.uuid + return Video.buildWatchUrl(video) } 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 { licence: VideoConstant language: VideoConstant privacy: VideoConstant + description: string + duration: number durationLabel: string + id: number uuid: string + shortUUID: string + isLocal: boolean + name: string serverHost: string thumbnailPath: string @@ -85,8 +91,12 @@ export class Video implements VideoServerModel { pluginData?: any - static buildClientUrl (videoUUID: string) { - return '/w/' + videoUUID + static buildWatchUrl (video: Partial>) { + return '/w/' + (video.shortUUID || video.uuid) + } + + static buildUpdateUrl (video: Pick) { + return '/videos/update/' + video.uuid } constructor (hash: VideoServerModel, translations = {}) { @@ -109,6 +119,7 @@ export class Video implements VideoServerModel { this.id = hash.id this.uuid = hash.uuid + this.shortUUID = hash.shortUUID this.isLocal = hash.isLocal 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 @@ import { Component, ElementRef, Input, ViewChild } from '@angular/core' -import { VideoDetails } from '@app/shared/shared-main' +import { Video, VideoDetails } from '@app/shared/shared-main' import { VideoPlaylist } from '@app/shared/shared-video-playlist' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { VideoCaption } from '@shared/models' @@ -98,14 +98,15 @@ export class VideoShareComponent { getVideoUrl () { let baseUrl = this.customizations.originUrl ? this.video.originInstanceUrl : window.location.origin - baseUrl += '/w/' + this.video.uuid + baseUrl += Video.buildWatchUrl(this.video) + const options = this.getVideoOptions(baseUrl) return buildVideoLink(options) } getPlaylistUrl () { - const base = window.location.origin + '/w/p/' + this.playlist.uuid + const base = window.location.origin + VideoPlaylist.buildWatchUrl(this.playlist) if (!this.includeVideoInPlaylist) return base 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 { @Input() video: Video @Input() nsfw = false - @Input() videoRouterLink: any[] + @Input() videoRouterLink: string | any[] @Input() queryParams: { [ p: string ]: any } @Input() videoHref: string @Input() videoTarget: string @@ -57,7 +57,7 @@ export class VideoThumbnailComponent { getVideoRouterLink () { if (this.videoRouterLink) return this.videoRouterLink - return [ '/w', this.video.uuid ] + return Video.buildWatchUrl(this.video) } 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 @@ import { getAbsoluteAPIUrl } from '@app/helpers' -import { Account, Actor } from '@app/shared/shared-main' +import { Account, Actor, Video } from '@app/shared/shared-main' import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models' export class VideoComment implements VideoCommentServerModel { @@ -85,7 +85,7 @@ export class VideoCommentAdmin implements VideoCommentAdminServerModel { id: hash.video.id, uuid: hash.video.uuid, name: hash.video.name, - localUrl: '/w/' + hash.video.uuid + localUrl: Video.buildWatchUrl(hash.video) } 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 { FeedFormat, ResultList, ThreadsResultList, + Video, VideoComment as VideoCommentServerModel, VideoCommentAdmin, VideoCommentCreate, @@ -127,7 +128,7 @@ export class VideoCommentService { ) } - getVideoCommentsFeeds (videoUUID?: string) { + getVideoCommentsFeeds (video: Pick) { const feeds = [ { format: FeedFormat.RSS, @@ -146,9 +147,9 @@ export class VideoCommentService { } ] - if (videoUUID !== undefined) { + if (video !== undefined) { for (const feed of feeds) { - feed.url += '?videoId=' + videoUUID + feed.url += '?videoId=' + video.uuid } } 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 { playlistElementId?: number } - videoRouterLink: any[] = [] + videoRouterLink: string | any[] = [] videoHref: string videoTarget: string @@ -120,7 +120,7 @@ export class VideoMiniatureComponent implements OnInit { buildVideoLink () { if (this.videoLinkType === 'internal' || !this.video.url) { - this.videoRouterLink = [ '/w', this.video.uuid ] + this.videoRouterLink = Video.buildWatchUrl(this.video) return } 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 { buildRouterLink () { if (!this.playlist) return null - return [ '/w/p', this.playlist.uuid ] + return VideoPlaylist.buildWatchUrl(this.playlist) } 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 { } if (this.linkType === 'internal' || !this.playlist.url) { - this.routerLink = [ '/w/p', this.playlist.uuid ] + this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist) return } 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 { export class VideoPlaylist implements ServerVideoPlaylist { id: number uuid: string + shortUUID: string + isLocal: boolean url: string @@ -41,11 +43,17 @@ export class VideoPlaylist implements ServerVideoPlaylist { videoChannelBy?: string + static buildWatchUrl (playlist: Pick) { + return '/w/p/' + (playlist.uuid || playlist.shortUUID) + } + constructor (hash: ServerVideoPlaylist, translations: {}) { const absoluteAPIUrl = getAbsoluteAPIUrl() this.id = hash.id this.uuid = hash.uuid + this.shortUUID = hash.shortUUID + this.url = hash.url this.isLocal = hash.isLocal -- cgit v1.2.3