aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-26 09:14:14 +0200
committerChocobozzz <me@florianbigard.com>2020-08-26 09:14:14 +0200
commite6abf95e9fc9fde52d583850cf7faafdf7d050d5 (patch)
tree704e5cb65e93a5d68d558a9b20a81e3909d8142c /client/src
parentca00baa75ae849b1ba4953f0ff843ff5452f6745 (diff)
downloadPeerTube-e6abf95e9fc9fde52d583850cf7faafdf7d050d5.tar.gz
PeerTube-e6abf95e9fc9fde52d583850cf7faafdf7d050d5.tar.zst
PeerTube-e6abf95e9fc9fde52d583850cf7faafdf7d050d5.zip
Add redirection on unavailable video due to follow constraints
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts
index 1b2820810..f048edec4 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -15,7 +15,7 @@ import { VideoDownloadComponent } from '@app/shared/shared-video-miniature'
15import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' 15import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
16import { MetaService } from '@ngx-meta/core' 16import { MetaService } from '@ngx-meta/core'
17import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 17import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
18import { ServerConfig, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' 18import { ServerConfig, ServerErrorCode, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
19import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage' 19import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage'
20import { 20import {
21 CustomizationOptions, 21 CustomizationOptions,
@@ -361,7 +361,24 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
361 ]) 361 ])
362 .pipe( 362 .pipe(
363 // If 401, the video is private or blocked so redirect to 404 363 // If 401, the video is private or blocked so redirect to 404
364 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])) 364 catchError(err => {
365 if (err.body.errorCode === ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS && err.body.originUrl) {
366 const search = window.location.search
367 let originUrl = err.body.originUrl
368 if (search) originUrl += search
369
370 this.confirmService.confirm(
371 $localize`This video is not available on this instance. Do you want to be redirected on the origin instance: <a href="${originUrl}">${originUrl}</a>?`,
372 $localize`Redirection`
373 ).then(res => {
374 if (res === false) return this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])
375
376 return window.location.href = originUrl
377 })
378 }
379
380 return this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])
381 })
365 ) 382 )
366 .subscribe(([ video, captionsResult ]) => { 383 .subscribe(([ video, captionsResult ]) => {
367 const queryParams = this.route.snapshot.queryParams 384 const queryParams = this.route.snapshot.queryParams