From f2eb23cd87cf32b8fe545178143b5f49e06a58da Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 8 Dec 2020 21:16:10 +0100 Subject: 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 --- shared/extra-utils/videos/video-history.ts | 8 +++++++- shared/extra-utils/videos/videos.ts | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'shared/extra-utils/videos') 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 @@ import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' -function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) { +function userWatchVideo ( + url: string, + token: string, + videoId: number | string, + currentTime: number, + statusCodeExpected = HttpStatusCode.NO_CONTENT_204 +) { const path = '/api/v1/videos/' + videoId + '/watching' const fields = { currentTime } 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 .set('Authorization', 'Bearer ' + token) .query(immutableAssign(query, { sort: 'name' })) .set('Accept', 'application/json') - .expect(200) + .expect(HttpStatusCode.OK_200) .expect('Content-Type', /json/) } @@ -166,7 +166,7 @@ function getLocalVideos (url: string) { .get(path) .query({ sort: 'name', filter: 'local' }) .set('Accept', 'application/json') - .expect(200) + .expect(HttpStatusCode.OK_200) .expect('Content-Type', /json/) } -- cgit v1.2.3