]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/utils/videos/video-blacklist.ts
Add ability to limit videos history size
[github/Chocobozzz/PeerTube.git] / shared / utils / videos / video-blacklist.ts
1 import * as request from 'supertest'
2
3 function addVideoToBlacklist (
4 url: string,
5 token: string,
6 videoId: number | string,
7 reason?: string,
8 unfederate?: boolean,
9 specialStatus = 204
10 ) {
11 const path = '/api/v1/videos/' + videoId + '/blacklist'
12
13 return request(url)
14 .post(path)
15 .send({ reason, unfederate })
16 .set('Accept', 'application/json')
17 .set('Authorization', 'Bearer ' + token)
18 .expect(specialStatus)
19 }
20
21 function 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)
29 .expect(specialStatus)
30 }
31
32 function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
33 const path = '/api/v1/videos/' + videoId + '/blacklist'
34
35 return request(url)
36 .delete(path)
37 .set('Accept', 'application/json')
38 .set('Authorization', 'Bearer ' + token)
39 .expect(specialStatus)
40 }
41
42 function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) {
43 const path = '/api/v1/videos/blacklist/'
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
54 function getBlacklistedVideosListWithTypeFilter (url: string, token: string, type: number, specialStatus = 200) {
55 const path = '/api/v1/videos/blacklist/'
56
57 return request(url)
58 .get(path)
59 .query({ sort: 'createdAt', type })
60 .set('Accept', 'application/json')
61 .set('Authorization', 'Bearer ' + token)
62 .expect(specialStatus)
63 .expect('Content-Type', /json/)
64 }
65
66 function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
67 const path = '/api/v1/videos/blacklist/'
68
69 return request(url)
70 .get(path)
71 .query({ sort: sort })
72 .set('Accept', 'application/json')
73 .set('Authorization', 'Bearer ' + token)
74 .expect(specialStatus)
75 .expect('Content-Type', /json/)
76 }
77
78 // ---------------------------------------------------------------------------
79
80 export {
81 addVideoToBlacklist,
82 removeVideoFromBlacklist,
83 getBlacklistedVideosList,
84 getBlacklistedVideosListWithTypeFilter,
85 getSortedBlacklistedVideosList,
86 updateVideoBlacklist
87 }