]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/videos/video-blacklist.ts
preserve original variable names server-side
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / video-blacklist.ts
CommitLineData
792dbaf0 1import * as request from 'supertest'
3487330d 2import { VideoBlacklistType } from '../../models/videos'
1eddc9a7 3import { makeGetRequest } from '..'
792dbaf0 4
5abb9fbb
C
5function addVideoToBlacklist (
6 url: string,
7 token: string,
8 videoId: number | string,
9 reason?: string,
10 unfederate?: boolean,
11 specialStatus = 204
12) {
792dbaf0
GS
13 const path = '/api/v1/videos/' + videoId + '/blacklist'
14
15 return request(url)
a1587156
C
16 .post(path)
17 .send({ reason, unfederate })
18 .set('Accept', 'application/json')
19 .set('Authorization', 'Bearer ' + token)
20 .expect(specialStatus)
792dbaf0
GS
21}
22
26b7305a
C
23function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) {
24 const path = '/api/v1/videos/' + videoId + '/blacklist'
25
26 return request(url)
27 .put(path)
28 .send({ reason })
29 .set('Accept', 'application/json')
30 .set('Authorization', 'Bearer ' + token)
191764f3
C
31 .expect(specialStatus)
32}
26b7305a 33
11ba2ab3 34function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
35bf0c83 35 const path = '/api/v1/videos/' + videoId + '/blacklist'
792dbaf0
GS
36
37 return request(url)
a1587156
C
38 .delete(path)
39 .set('Accept', 'application/json')
40 .set('Authorization', 'Bearer ' + token)
41 .expect(specialStatus)
792dbaf0
GS
42}
43
1eddc9a7 44function getBlacklistedVideosList (parameters: {
a1587156
C
45 url: string
46 token: string
47 sort?: string
3487330d 48 type?: VideoBlacklistType
1eddc9a7
C
49 specialStatus?: number
50}) {
a1587156 51 const { url, token, sort, type, specialStatus = 200 } = parameters
35bf0c83 52 const path = '/api/v1/videos/blacklist/'
792dbaf0 53
1eddc9a7 54 const query = { sort, type }
7ccddd7b 55
1eddc9a7
C
56 return makeGetRequest({
57 url,
58 path,
59 query,
60 token,
61 statusCodeExpected: specialStatus
62 })
792dbaf0
GS
63}
64
65// ---------------------------------------------------------------------------
66
67export {
68 addVideoToBlacklist,
69 removeVideoFromBlacklist,
70 getBlacklistedVideosList,
26b7305a 71 updateVideoBlacklist
792dbaf0 72}