diff options
Diffstat (limited to 'client/src')
5 files changed, 21 insertions, 11 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 727bbc32f..15178a267 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts | |||
@@ -8,7 +8,7 @@ import { FormValidatorService } from '@app/shared/shared-forms' | |||
8 | import { VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 8 | import { VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
9 | import { LiveVideoService } from '@app/shared/shared-video-live' | 9 | import { LiveVideoService } from '@app/shared/shared-video-live' |
10 | import { LoadingBarService } from '@ngx-loading-bar/core' | 10 | import { LoadingBarService } from '@ngx-loading-bar/core' |
11 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, ServerErrorCode, VideoPrivacy } from '@shared/models' | 11 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy } from '@shared/models' |
12 | import { VideoSend } from './video-send' | 12 | import { VideoSend } from './video-send' |
13 | 13 | ||
14 | @Component({ | 14 | @Component({ |
@@ -92,9 +92,11 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
92 | 92 | ||
93 | let message = err.message | 93 | let message = err.message |
94 | 94 | ||
95 | if (err.body?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { | 95 | const error = err.body as PeerTubeProblemDocument |
96 | |||
97 | if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { | ||
96 | message = $localize`Cannot create live because this instance have too many created lives` | 98 | message = $localize`Cannot create live because this instance have too many created lives` |
97 | } else if (err.body?.code) { | 99 | } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) { |
98 | message = $localize`Cannot create live because you created too many lives` | 100 | message = $localize`Cannot create live because you created too many lives` |
99 | } | 101 | } |
100 | 102 | ||
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts index 23bd5ef76..2837b30c1 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts | |||
@@ -5,7 +5,7 @@ import { scrollToTop } from '@app/helpers' | |||
5 | import { FormValidatorService } from '@app/shared/shared-forms' | 5 | import { FormValidatorService } from '@app/shared/shared-forms' |
6 | import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' | 6 | import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' |
7 | import { LoadingBarService } from '@ngx-loading-bar/core' | 7 | import { LoadingBarService } from '@ngx-loading-bar/core' |
8 | import { ServerErrorCode, VideoPrivacy, VideoUpdate } from '@shared/models' | 8 | import { PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy, VideoUpdate } from '@shared/models' |
9 | import { hydrateFormFromVideo } from '../shared/video-edit-utils' | 9 | import { hydrateFormFromVideo } from '../shared/video-edit-utils' |
10 | import { VideoSend } from './video-send' | 10 | import { VideoSend } from './video-send' |
11 | 11 | ||
@@ -115,7 +115,9 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af | |||
115 | this.firstStepError.emit() | 115 | this.firstStepError.emit() |
116 | 116 | ||
117 | let message = err.message | 117 | let message = err.message |
118 | if (err.body?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { | 118 | |
119 | const error = err.body as PeerTubeProblemDocument | ||
120 | if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { | ||
119 | message = $localize`Torrents with only 1 file are supported.` | 121 | message = $localize`Torrents with only 1 file are supported.` |
120 | } | 122 | } |
121 | 123 | ||
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 8034ccebf..540b568ed 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts | |||
@@ -28,7 +28,7 @@ import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/sha | |||
28 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' | 28 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' |
29 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 29 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
30 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 30 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
31 | import { ServerConfig, ServerErrorCode, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' | 31 | import { PeerTubeProblemDocument, ServerConfig, ServerErrorCode, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' |
32 | import { | 32 | import { |
33 | cleanupVideoWatch, | 33 | cleanupVideoWatch, |
34 | getStoredP2PEnabled, | 34 | getStoredP2PEnabled, |
@@ -431,9 +431,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
431 | .pipe( | 431 | .pipe( |
432 | // If 400, 403 or 404, the video is private or blocked so redirect to 404 | 432 | // If 400, 403 or 404, the video is private or blocked so redirect to 404 |
433 | catchError(err => { | 433 | catchError(err => { |
434 | if (err.body.type === ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS && err.body.originUrl) { | 434 | const errorBody = err.body as PeerTubeProblemDocument |
435 | |||
436 | if (errorBody.code === ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS && errorBody.originUrl) { | ||
435 | const search = window.location.search | 437 | const search = window.location.search |
436 | let originUrl = err.body.originUrl | 438 | let originUrl = errorBody.originUrl |
437 | if (search) originUrl += search | 439 | if (search) originUrl += search |
438 | 440 | ||
439 | this.confirmService.confirm( | 441 | this.confirmService.confirm( |
diff --git a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts index 4fe3b964d..5bcad36d0 100644 --- a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts +++ b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts | |||
@@ -5,6 +5,7 @@ import { Injectable, Injector } from '@angular/core' | |||
5 | import { AuthService } from '@app/core/auth/auth.service' | 5 | import { AuthService } from '@app/core/auth/auth.service' |
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
7 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
8 | import { OAuth2ErrorCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models/server' | ||
8 | 9 | ||
9 | @Injectable() | 10 | @Injectable() |
10 | export class AuthInterceptor implements HttpInterceptor { | 11 | export class AuthInterceptor implements HttpInterceptor { |
@@ -25,7 +26,9 @@ export class AuthInterceptor implements HttpInterceptor { | |||
25 | return next.handle(authReq) | 26 | return next.handle(authReq) |
26 | .pipe( | 27 | .pipe( |
27 | catchError((err: HttpErrorResponse) => { | 28 | catchError((err: HttpErrorResponse) => { |
28 | if (err.status === HttpStatusCode.UNAUTHORIZED_401 && err.error && err.error.code === 'invalid_token') { | 29 | const error = err.error as PeerTubeProblemDocument |
30 | |||
31 | if (err.status === HttpStatusCode.UNAUTHORIZED_401 && error && error.code === OAuth2ErrorCode.INVALID_TOKEN) { | ||
29 | return this.handleTokenExpired(req, next) | 32 | return this.handleTokenExpired(req, next) |
30 | } | 33 | } |
31 | 34 | ||
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index fc61d3730..4ce5c78e8 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -5,6 +5,7 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c | |||
5 | import { | 5 | import { |
6 | ClientHookName, | 6 | ClientHookName, |
7 | HTMLServerConfig, | 7 | HTMLServerConfig, |
8 | OAuth2ErrorCode, | ||
8 | PluginType, | 9 | PluginType, |
9 | ResultList, | 10 | ResultList, |
10 | UserRefreshToken, | 11 | UserRefreshToken, |
@@ -118,8 +119,8 @@ export class PeerTubeEmbed { | |||
118 | if (res.status === HttpStatusCode.UNAUTHORIZED_401) return undefined | 119 | if (res.status === HttpStatusCode.UNAUTHORIZED_401) return undefined |
119 | 120 | ||
120 | return res.json() | 121 | return res.json() |
121 | }).then((obj: UserRefreshToken & { code: 'invalid_grant'}) => { | 122 | }).then((obj: UserRefreshToken & { code?: OAuth2ErrorCode }) => { |
122 | if (!obj || obj.code === 'invalid_grant') { | 123 | if (!obj || obj.code === OAuth2ErrorCode.INVALID_GRANT) { |
123 | Tokens.flush() | 124 | Tokens.flush() |
124 | this.removeTokensFromHeaders() | 125 | this.removeTokensFromHeaders() |
125 | 126 | ||