]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Provide origin URL to client and fix remote share
authorChocobozzz <me@florianbigard.com>
Fri, 22 Oct 2021 12:11:58 +0000 (14:11 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 22 Oct 2021 12:11:58 +0000 (14:11 +0200)
client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html
client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
client/src/app/shared/shared-main/video/video.model.ts
client/src/app/shared/shared-share-modal/video-share.component.ts
server/models/video/formatter/video-format-utils.ts
shared/extra-utils/videos/videos.ts
shared/models/videos/video.model.ts

index 362a2190514c2fe34c688693d98565d695f1471b..d65c9356af8b73a08671ba3fb605637a6fc84007 100644 (file)
@@ -12,7 +12,7 @@
 
   <a
     i18n-title title="Open the video on the origin instance" class="glyphicon glyphicon-new-window"
-    target="_blank" rel="noopener noreferrer" [href]="getVideoUrl()"
+    target="_blank" rel="noopener noreferrer" [href]="video.url"
   ></a>
 </div>
 
index 9429581ac7ce6ebbe386ae56763f26a5baa092a8..b8f564c4c7922f58074b7a9c7a731f570784620b 100644 (file)
@@ -9,14 +9,6 @@ import { VideoDetails } from '@app/shared/shared-main'
 export class VideoAttributesComponent {
   @Input() video: VideoDetails
 
-  getVideoUrl () {
-    if (!this.video.url) {
-      return this.video.originInstanceUrl + VideoDetails.buildWatchUrl(this.video)
-    }
-
-    return this.video.url
-  }
-
   getVideoHost () {
     return this.video.channel.host
   }
index 7471a933b2006e3a6e9a8b22534b0f24752b606d..10caec014ffb81d91e1ad86d278da32f361ff151 100644 (file)
@@ -52,7 +52,7 @@ export class Video implements VideoServerModel {
   embedPath: string
   embedUrl: string
 
-  url?: string
+  url: string
 
   views: number
   likes: number
index 341abdc2b7eb0a8deac72a165db282a4309ba966..70890e551fa40d6475b7aae9fdcb0fc2c9b93ddb 100644 (file)
@@ -96,12 +96,12 @@ export class VideoShareComponent {
   }
 
   getVideoUrl () {
-    const baseUrl = this.customizations.originUrl
-      ? this.video.originInstanceUrl
-      : window.location.origin
+    const url = this.customizations.originUrl
+      ? this.video.url
+      : buildVideoLink(this.video, window.location.origin)
 
     return decorateVideoLink({
-      url: buildVideoLink(this.video, baseUrl),
+      url,
 
       ...this.getVideoOptions()
     })
index b3c4f390d1e0945cc468bab6dd22de05a2417d9e..0cbad568452e23a03a437047deb530f594ea427d 100644 (file)
@@ -50,6 +50,8 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFor
     uuid: video.uuid,
     shortUUID: uuidToShort(video.uuid),
 
+    url: video.url,
+
     name: video.name,
     category: {
       id: video.category,
index a1d2ba0fc14fdde45a37da288399ed751dbf8dd4..4d2784dde8393178de858742a33df8450ec61f6c 100644 (file)
@@ -113,7 +113,7 @@ async function completeVideoCheck (
     channel: {
       displayName: string
       name: string
-      description
+      description: string
       isLocal: boolean
     }
     fixture: string
@@ -151,6 +151,7 @@ async function completeVideoCheck (
   expect(video.dislikes).to.equal(attributes.dislikes)
   expect(video.isLocal).to.equal(attributes.isLocal)
   expect(video.duration).to.equal(attributes.duration)
+  expect(video.url).to.contain(originHost)
   expect(dateIsValid(video.createdAt)).to.be.true
   expect(dateIsValid(video.publishedAt)).to.be.true
   expect(dateIsValid(video.updatedAt)).to.be.true
index 0e3e89f43b1777ce254d683138d45d1562de5055..4a7e399a228ffa44a7fa51cf56090c97d88a40c0 100644 (file)
@@ -36,8 +36,7 @@ export interface Video {
   embedPath: string
   embedUrl?: string
 
-  // When using the search index
-  url?: string
+  url: string
 
   views: number
   likes: number