Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Provide origin URL to client and fix remote share

Chocobozzzab4001aade08
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html
index 362a219051..d65c9356af 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html
@@ -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>
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
index 9429581ac7..b8f564c4c7 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
@@ -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
}
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 7471a933b2..10caec014f 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -52,7 +52,7 @@ export class Video implements VideoServerModel {
embedPath: string
embedUrl: string
- url?: string
+ url: string
views: number
likes: number
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 341abdc2b7..70890e551f 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
@@ -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()
})
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts
index b3c4f390d1..0cbad56845 100644
--- a/server/models/video/formatter/video-format-utils.ts
+++ b/server/models/video/formatter/video-format-utils.ts
@@ -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,
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index a1d2ba0fc1..4d2784dde8 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -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
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts
index 0e3e89f43b..4a7e399a22 100644
--- a/shared/models/videos/video.model.ts
+++ b/shared/models/videos/video.model.ts
@@ -36,8 +36,7 @@ export interface Video {
embedPath: string
embedUrl?: string
- // When using the search index
- url?: string
+ url: string
views: number
likes: number