diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-08 11:17:55 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | e3d15a6a9aed97a004d9dac1b7a6499d794e080a (patch) | |
tree | 7637ac85a8659a66a1290c9533e0206e9a0c5a30 /shared/extra-utils/videos/video-blacklist.ts | |
parent | a1637fa1e25b60a88f7cfe50aac8953f50d55761 (diff) | |
download | PeerTube-e3d15a6a9aed97a004d9dac1b7a6499d794e080a.tar.gz PeerTube-e3d15a6a9aed97a004d9dac1b7a6499d794e080a.tar.zst PeerTube-e3d15a6a9aed97a004d9dac1b7a6499d794e080a.zip |
Introduce blacklist command
Diffstat (limited to 'shared/extra-utils/videos/video-blacklist.ts')
-rw-r--r-- | shared/extra-utils/videos/video-blacklist.ts | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/shared/extra-utils/videos/video-blacklist.ts b/shared/extra-utils/videos/video-blacklist.ts deleted file mode 100644 index aa1548537..000000000 --- a/shared/extra-utils/videos/video-blacklist.ts +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { VideoBlacklistType } from '../../models/videos' | ||
3 | import { makeGetRequest } from '..' | ||
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
5 | |||
6 | function addVideoToBlacklist ( | ||
7 | url: string, | ||
8 | token: string, | ||
9 | videoId: number | string, | ||
10 | reason?: string, | ||
11 | unfederate?: boolean, | ||
12 | specialStatus = HttpStatusCode.NO_CONTENT_204 | ||
13 | ) { | ||
14 | const path = '/api/v1/videos/' + videoId + '/blacklist' | ||
15 | |||
16 | return request(url) | ||
17 | .post(path) | ||
18 | .send({ reason, unfederate }) | ||
19 | .set('Accept', 'application/json') | ||
20 | .set('Authorization', 'Bearer ' + token) | ||
21 | .expect(specialStatus) | ||
22 | } | ||
23 | |||
24 | function updateVideoBlacklist ( | ||
25 | url: string, | ||
26 | token: string, | ||
27 | videoId: number, | ||
28 | reason?: string, | ||
29 | specialStatus = HttpStatusCode.NO_CONTENT_204 | ||
30 | ) { | ||
31 | const path = '/api/v1/videos/' + videoId + '/blacklist' | ||
32 | |||
33 | return request(url) | ||
34 | .put(path) | ||
35 | .send({ reason }) | ||
36 | .set('Accept', 'application/json') | ||
37 | .set('Authorization', 'Bearer ' + token) | ||
38 | .expect(specialStatus) | ||
39 | } | ||
40 | |||
41 | function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = HttpStatusCode.NO_CONTENT_204) { | ||
42 | const path = '/api/v1/videos/' + videoId + '/blacklist' | ||
43 | |||
44 | return request(url) | ||
45 | .delete(path) | ||
46 | .set('Accept', 'application/json') | ||
47 | .set('Authorization', 'Bearer ' + token) | ||
48 | .expect(specialStatus) | ||
49 | } | ||
50 | |||
51 | function getBlacklistedVideosList (parameters: { | ||
52 | url: string | ||
53 | token: string | ||
54 | sort?: string | ||
55 | type?: VideoBlacklistType | ||
56 | specialStatus?: HttpStatusCode | ||
57 | }) { | ||
58 | const { url, token, sort, type, specialStatus = HttpStatusCode.OK_200 } = parameters | ||
59 | const path = '/api/v1/videos/blacklist/' | ||
60 | |||
61 | const query = { sort, type } | ||
62 | |||
63 | return makeGetRequest({ | ||
64 | url, | ||
65 | path, | ||
66 | query, | ||
67 | token, | ||
68 | statusCodeExpected: specialStatus | ||
69 | }) | ||
70 | } | ||
71 | |||
72 | // --------------------------------------------------------------------------- | ||
73 | |||
74 | export { | ||
75 | addVideoToBlacklist, | ||
76 | removeVideoFromBlacklist, | ||
77 | getBlacklistedVideosList, | ||
78 | updateVideoBlacklist | ||
79 | } | ||