]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/utils/videos/video-blacklist.ts
Add ability to limit videos history size
[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
7ccddd7b
JM
54function 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
792dbaf0 66function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
35bf0c83 67 const path = '/api/v1/videos/blacklist/'
792dbaf0
GS
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
80export {
81 addVideoToBlacklist,
82 removeVideoFromBlacklist,
83 getBlacklistedVideosList,
7ccddd7b 84 getBlacklistedVideosListWithTypeFilter,
26b7305a
C
85 getSortedBlacklistedVideosList,
86 updateVideoBlacklist
792dbaf0 87}