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