aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-08 21:16:10 +0100
committerGitHub <noreply@github.com>2020-12-08 21:16:10 +0100
commitf2eb23cd87cf32b8fe545178143b5f49e06a58da (patch)
treeaf7d59945af70e28fd85047e2c688c59a908f548 /shared/extra-utils/videos
parentc977fd3ec931c059111ddb2b8d6ddbb20b6b99a1 (diff)
downloadPeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.gz
PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.zst
PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.zip
emit more specific status codes on video upload (#3423)
- reduce http status codes list to potentially useful codes - convert more codes to typed ones - factorize html generator for error responses
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r--shared/extra-utils/videos/video-history.ts8
-rw-r--r--shared/extra-utils/videos/videos.ts4
2 files changed, 9 insertions, 3 deletions
diff --git a/shared/extra-utils/videos/video-history.ts b/shared/extra-utils/videos/video-history.ts
index 2d751cf14..0dd3afb24 100644
--- a/shared/extra-utils/videos/video-history.ts
+++ b/shared/extra-utils/videos/video-history.ts
@@ -1,7 +1,13 @@
1import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' 1import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3 3
4function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) { 4function userWatchVideo (
5 url: string,
6 token: string,
7 videoId: number | string,
8 currentTime: number,
9 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
10) {
5 const path = '/api/v1/videos/' + videoId + '/watching' 11 const path = '/api/v1/videos/' + videoId + '/watching'
6 const fields = { currentTime } 12 const fields = { currentTime }
7 13
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index a4b9d688e..a2438d712 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -155,7 +155,7 @@ function getVideosListWithToken (url: string, token: string, query: { nsfw?: boo
155 .set('Authorization', 'Bearer ' + token) 155 .set('Authorization', 'Bearer ' + token)
156 .query(immutableAssign(query, { sort: 'name' })) 156 .query(immutableAssign(query, { sort: 'name' }))
157 .set('Accept', 'application/json') 157 .set('Accept', 'application/json')
158 .expect(200) 158 .expect(HttpStatusCode.OK_200)
159 .expect('Content-Type', /json/) 159 .expect('Content-Type', /json/)
160} 160}
161 161
@@ -166,7 +166,7 @@ function getLocalVideos (url: string) {
166 .get(path) 166 .get(path)
167 .query({ sort: 'name', filter: 'local' }) 167 .query({ sort: 'name', filter: 'local' })
168 .set('Accept', 'application/json') 168 .set('Accept', 'application/json')
169 .expect(200) 169 .expect(HttpStatusCode.OK_200)
170 .expect('Content-Type', /json/) 170 .expect('Content-Type', /json/)
171} 171}
172 172