diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /shared/extra-utils/videos/video-blacklist.ts | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip |
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'shared/extra-utils/videos/video-blacklist.ts')
-rw-r--r-- | shared/extra-utils/videos/video-blacklist.ts | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/shared/extra-utils/videos/video-blacklist.ts b/shared/extra-utils/videos/video-blacklist.ts index ba139ef95..aa1548537 100644 --- a/shared/extra-utils/videos/video-blacklist.ts +++ b/shared/extra-utils/videos/video-blacklist.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { VideoBlacklistType } from '../../models/videos' | 2 | import { VideoBlacklistType } from '../../models/videos' |
3 | import { makeGetRequest } from '..' | 3 | import { makeGetRequest } from '..' |
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
4 | 5 | ||
5 | function addVideoToBlacklist ( | 6 | function addVideoToBlacklist ( |
6 | url: string, | 7 | url: string, |
@@ -8,7 +9,7 @@ function addVideoToBlacklist ( | |||
8 | videoId: number | string, | 9 | videoId: number | string, |
9 | reason?: string, | 10 | reason?: string, |
10 | unfederate?: boolean, | 11 | unfederate?: boolean, |
11 | specialStatus = 204 | 12 | specialStatus = HttpStatusCode.NO_CONTENT_204 |
12 | ) { | 13 | ) { |
13 | const path = '/api/v1/videos/' + videoId + '/blacklist' | 14 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
14 | 15 | ||
@@ -20,7 +21,13 @@ function addVideoToBlacklist ( | |||
20 | .expect(specialStatus) | 21 | .expect(specialStatus) |
21 | } | 22 | } |
22 | 23 | ||
23 | function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) { | 24 | function updateVideoBlacklist ( |
25 | url: string, | ||
26 | token: string, | ||
27 | videoId: number, | ||
28 | reason?: string, | ||
29 | specialStatus = HttpStatusCode.NO_CONTENT_204 | ||
30 | ) { | ||
24 | const path = '/api/v1/videos/' + videoId + '/blacklist' | 31 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
25 | 32 | ||
26 | return request(url) | 33 | return request(url) |
@@ -31,7 +38,7 @@ function updateVideoBlacklist (url: string, token: string, videoId: number, reas | |||
31 | .expect(specialStatus) | 38 | .expect(specialStatus) |
32 | } | 39 | } |
33 | 40 | ||
34 | function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) { | 41 | function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = HttpStatusCode.NO_CONTENT_204) { |
35 | const path = '/api/v1/videos/' + videoId + '/blacklist' | 42 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
36 | 43 | ||
37 | return request(url) | 44 | return request(url) |
@@ -46,9 +53,9 @@ function getBlacklistedVideosList (parameters: { | |||
46 | token: string | 53 | token: string |
47 | sort?: string | 54 | sort?: string |
48 | type?: VideoBlacklistType | 55 | type?: VideoBlacklistType |
49 | specialStatus?: number | 56 | specialStatus?: HttpStatusCode |
50 | }) { | 57 | }) { |
51 | const { url, token, sort, type, specialStatus = 200 } = parameters | 58 | const { url, token, sort, type, specialStatus = HttpStatusCode.OK_200 } = parameters |
52 | const path = '/api/v1/videos/blacklist/' | 59 | const path = '/api/v1/videos/blacklist/' |
53 | 60 | ||
54 | const query = { sort, type } | 61 | const query = { sort, type } |