aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/embed.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r--client/src/standalone/videos/embed.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 48f7e7749..1709d44e7 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -13,6 +13,7 @@ import {
13 PluginType, 13 PluginType,
14 ClientHookName 14 ClientHookName
15} from '../../../../shared/models' 15} from '../../../../shared/models'
16import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
16import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player/peertube-player-manager' 17import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player/peertube-player-manager'
17import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' 18import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
18import { TranslationsManager } from '../../assets/player/translations-manager' 19import { TranslationsManager } from '../../assets/player/translations-manager'
@@ -85,7 +86,7 @@ export class PeerTubeEmbed {
85 refreshFetch (url: string, options?: RequestInit) { 86 refreshFetch (url: string, options?: RequestInit) {
86 return fetch(url, options) 87 return fetch(url, options)
87 .then((res: Response) => { 88 .then((res: Response) => {
88 if (res.status !== 401) return res 89 if (res.status !== HttpStatusCode.UNAUTHORIZED_401) return res
89 90
90 const refreshingTokenPromise = new Promise((resolve, reject) => { 91 const refreshingTokenPromise = new Promise((resolve, reject) => {
91 const clientId: string = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) 92 const clientId: string = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID)
@@ -107,7 +108,7 @@ export class PeerTubeEmbed {
107 method: 'POST', 108 method: 'POST',
108 body: objectToUrlEncoded(data) 109 body: objectToUrlEncoded(data)
109 }).then(res => { 110 }).then(res => {
110 if (res.status === 401) return undefined 111 if (res.status === HttpStatusCode.UNAUTHORIZED_401) return undefined
111 112
112 return res.json() 113 return res.json()
113 }).then((obj: UserRefreshToken & { code: 'invalid_grant'}) => { 114 }).then((obj: UserRefreshToken & { code: 'invalid_grant'}) => {
@@ -338,7 +339,7 @@ export class PeerTubeEmbed {
338 339
339 try { 340 try {
340 playlistResponse = await playlistPromise 341 playlistResponse = await playlistPromise
341 isResponseOk = playlistResponse.status === 200 342 isResponseOk = playlistResponse.status === HttpStatusCode.OK_200
342 } catch (err) { 343 } catch (err) {
343 console.error(err) 344 console.error(err)
344 isResponseOk = false 345 isResponseOk = false
@@ -347,7 +348,7 @@ export class PeerTubeEmbed {
347 if (!isResponseOk) { 348 if (!isResponseOk) {
348 const serverTranslations = await this.translationsPromise 349 const serverTranslations = await this.translationsPromise
349 350
350 if (playlistResponse?.status === 404) { 351 if (playlistResponse?.status === HttpStatusCode.NOT_FOUND_404) {
351 this.playlistNotFound(serverTranslations) 352 this.playlistNotFound(serverTranslations)
352 return undefined 353 return undefined
353 } 354 }
@@ -367,7 +368,7 @@ export class PeerTubeEmbed {
367 368
368 try { 369 try {
369 videoResponse = await videoPromise 370 videoResponse = await videoPromise
370 isResponseOk = videoResponse.status === 200 371 isResponseOk = videoResponse.status === HttpStatusCode.OK_200
371 } catch (err) { 372 } catch (err) {
372 console.error(err) 373 console.error(err)
373 374
@@ -377,7 +378,7 @@ export class PeerTubeEmbed {
377 if (!isResponseOk) { 378 if (!isResponseOk) {
378 const serverTranslations = await this.translationsPromise 379 const serverTranslations = await this.translationsPromise
379 380
380 if (videoResponse?.status === 404) { 381 if (videoResponse?.status === HttpStatusCode.NOT_FOUND_404) {
381 this.videoNotFound(serverTranslations) 382 this.videoNotFound(serverTranslations)
382 return undefined 383 return undefined
383 } 384 }