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