aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/video-abuses.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-06 17:39:07 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-07 08:33:34 +0200
commitfeb34f6b6b991046aab6a10df747b48fa4da07a7 (patch)
tree02bb7277d45be166ba48caef2ee73bf89dbe1258 /shared/extra-utils/videos/video-abuses.ts
parentd170c5c580abf6f90d7bf144e2417e248ce2ecf4 (diff)
downloadPeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.tar.gz
PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.tar.zst
PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.zip
Use video abuse filters on client side
Diffstat (limited to 'shared/extra-utils/videos/video-abuses.ts')
-rw-r--r--shared/extra-utils/videos/video-abuses.ts55
1 files changed, 46 insertions, 9 deletions
diff --git a/shared/extra-utils/videos/video-abuses.ts b/shared/extra-utils/videos/video-abuses.ts
index 7f011ec0f..81582bfc7 100644
--- a/shared/extra-utils/videos/video-abuses.ts
+++ b/shared/extra-utils/videos/video-abuses.ts
@@ -1,6 +1,8 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' 2import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model'
3import { makeDeleteRequest, makePutBodyRequest } from '../requests/requests' 3import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests'
4import { VideoAbuseState } from '@shared/models'
5import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type'
4 6
5function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) { 7function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) {
6 const path = '/api/v1/videos/' + videoId + '/abuse' 8 const path = '/api/v1/videos/' + videoId + '/abuse'
@@ -13,16 +15,51 @@ function reportVideoAbuse (url: string, token: string, videoId: number | string,
13 .expect(specialStatus) 15 .expect(specialStatus)
14} 16}
15 17
16function getVideoAbusesList (url: string, token: string) { 18function getVideoAbusesList (options: {
19 url: string
20 token: string
21 id?: number
22 search?: string
23 state?: VideoAbuseState
24 videoIs?: VideoAbuseVideoIs
25 searchReporter?: string
26 searchReportee?: string
27 searchVideo?: string
28 searchVideoChannel?: string
29}) {
30 const {
31 url,
32 token,
33 id,
34 search,
35 state,
36 videoIs,
37 searchReporter,
38 searchReportee,
39 searchVideo,
40 searchVideoChannel
41 } = options
17 const path = '/api/v1/videos/abuse' 42 const path = '/api/v1/videos/abuse'
18 43
19 return request(url) 44 const query = {
20 .get(path) 45 sort: 'createdAt',
21 .query({ sort: 'createdAt' }) 46 id,
22 .set('Accept', 'application/json') 47 search,
23 .set('Authorization', 'Bearer ' + token) 48 state,
24 .expect(200) 49 videoIs,
25 .expect('Content-Type', /json/) 50 searchReporter,
51 searchReportee,
52 searchVideo,
53 searchVideoChannel
54 }
55
56 return makeGetRequest({
57 url,
58 path,
59 token,
60 query,
61 statusCodeExpected: 200
62 })
26} 63}
27 64
28function updateVideoAbuse ( 65function updateVideoAbuse (