]>
Commit | Line | Data |
---|---|---|
792dbaf0 | 1 | import * as request from 'supertest' |
1eddc9a7 C |
2 | import { VideoBlacklistType } from '../../models/videos' |
3 | import { makeGetRequest } from '..' | |
2d53be02 | 4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
792dbaf0 | 5 | |
5abb9fbb C |
6 | function addVideoToBlacklist ( |
7 | url: string, | |
8 | token: string, | |
9 | videoId: number | string, | |
10 | reason?: string, | |
11 | unfederate?: boolean, | |
2d53be02 | 12 | specialStatus = HttpStatusCode.NO_CONTENT_204 |
5abb9fbb | 13 | ) { |
792dbaf0 GS |
14 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
15 | ||
16 | return request(url) | |
a1587156 C |
17 | .post(path) |
18 | .send({ reason, unfederate }) | |
19 | .set('Accept', 'application/json') | |
20 | .set('Authorization', 'Bearer ' + token) | |
21 | .expect(specialStatus) | |
792dbaf0 GS |
22 | } |
23 | ||
2d53be02 RK |
24 | function updateVideoBlacklist ( |
25 | url: string, | |
26 | token: string, | |
27 | videoId: number, | |
28 | reason?: string, | |
29 | specialStatus = HttpStatusCode.NO_CONTENT_204 | |
30 | ) { | |
26b7305a C |
31 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
32 | ||
33 | return request(url) | |
34 | .put(path) | |
35 | .send({ reason }) | |
36 | .set('Accept', 'application/json') | |
37 | .set('Authorization', 'Bearer ' + token) | |
191764f3 C |
38 | .expect(specialStatus) |
39 | } | |
26b7305a | 40 | |
2d53be02 | 41 | function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = HttpStatusCode.NO_CONTENT_204) { |
35bf0c83 | 42 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
792dbaf0 GS |
43 | |
44 | return request(url) | |
a1587156 C |
45 | .delete(path) |
46 | .set('Accept', 'application/json') | |
47 | .set('Authorization', 'Bearer ' + token) | |
48 | .expect(specialStatus) | |
792dbaf0 GS |
49 | } |
50 | ||
1eddc9a7 | 51 | function getBlacklistedVideosList (parameters: { |
a1587156 C |
52 | url: string |
53 | token: string | |
54 | sort?: string | |
55 | type?: VideoBlacklistType | |
2d53be02 | 56 | specialStatus?: HttpStatusCode |
1eddc9a7 | 57 | }) { |
2d53be02 | 58 | const { url, token, sort, type, specialStatus = HttpStatusCode.OK_200 } = parameters |
35bf0c83 | 59 | const path = '/api/v1/videos/blacklist/' |
792dbaf0 | 60 | |
1eddc9a7 | 61 | const query = { sort, type } |
7ccddd7b | 62 | |
1eddc9a7 C |
63 | return makeGetRequest({ |
64 | url, | |
65 | path, | |
66 | query, | |
67 | token, | |
68 | statusCodeExpected: specialStatus | |
69 | }) | |
792dbaf0 GS |
70 | } |
71 | ||
72 | // --------------------------------------------------------------------------- | |
73 | ||
74 | export { | |
75 | addVideoToBlacklist, | |
76 | removeVideoFromBlacklist, | |
77 | getBlacklistedVideosList, | |
26b7305a | 78 | updateVideoBlacklist |
792dbaf0 | 79 | } |