]>
Commit | Line | Data |
---|---|---|
1 | import * as request from 'supertest' | |
2 | import { VideoAbuseUpdate } from '../../../../shared/models/videos/abuse/video-abuse-update.model' | |
3 | import { makeDeleteRequest, makePutBodyRequest } from '..' | |
4 | ||
5 | function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) { | |
6 | const path = '/api/v1/videos/' + videoId + '/abuse' | |
7 | ||
8 | return request(url) | |
9 | .post(path) | |
10 | .set('Accept', 'application/json') | |
11 | .set('Authorization', 'Bearer ' + token) | |
12 | .send({ reason }) | |
13 | .expect(specialStatus) | |
14 | } | |
15 | ||
16 | function getVideoAbusesList (url: string, token: string) { | |
17 | const path = '/api/v1/videos/abuse' | |
18 | ||
19 | return request(url) | |
20 | .get(path) | |
21 | .query({ sort: 'createdAt' }) | |
22 | .set('Accept', 'application/json') | |
23 | .set('Authorization', 'Bearer ' + token) | |
24 | .expect(200) | |
25 | .expect('Content-Type', /json/) | |
26 | } | |
27 | ||
28 | function updateVideoAbuse ( | |
29 | url: string, | |
30 | token: string, | |
31 | videoId: string | number, | |
32 | videoAbuseId: number, | |
33 | body: VideoAbuseUpdate, | |
34 | statusCodeExpected = 204 | |
35 | ) { | |
36 | const path = '/api/v1/videos/' + videoId + '/abuse/' + videoAbuseId | |
37 | ||
38 | return makePutBodyRequest({ | |
39 | url, | |
40 | token, | |
41 | path, | |
42 | fields: body, | |
43 | statusCodeExpected | |
44 | }) | |
45 | } | |
46 | ||
47 | function deleteVideoAbuse (url: string, token: string, videoId: string | number, videoAbuseId: number, statusCodeExpected = 204) { | |
48 | const path = '/api/v1/videos/' + videoId + '/abuse/' + videoAbuseId | |
49 | ||
50 | return makeDeleteRequest({ | |
51 | url, | |
52 | token, | |
53 | path, | |
54 | statusCodeExpected | |
55 | }) | |
56 | } | |
57 | ||
58 | // --------------------------------------------------------------------------- | |
59 | ||
60 | export { | |
61 | reportVideoAbuse, | |
62 | getVideoAbusesList, | |
63 | updateVideoAbuse, | |
64 | deleteVideoAbuse | |
65 | } |