diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-06-22 13:00:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 13:00:39 +0200 |
commit | 1ebddadd0704812a4600c39cabe2268321e88331 (patch) | |
tree | 1cc8560e5b63e9976aa5411ba800a62cfe7b8ea9 /shared/extra-utils/videos/video-abuses.ts | |
parent | 07aea1a2642fc9868cb01e30c322514029d5b95a (diff) | |
download | PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.tar.gz PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.tar.zst PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.zip |
predefined report reasons & improved reporter UI (#2842)
- added `startAt` and `endAt` optional timestamps to help pin down reported sections of a video
- added predefined report reasons
- added video player with report modal
Diffstat (limited to 'shared/extra-utils/videos/video-abuses.ts')
-rw-r--r-- | shared/extra-utils/videos/video-abuses.ts | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/shared/extra-utils/videos/video-abuses.ts b/shared/extra-utils/videos/video-abuses.ts index 81582bfc7..ff006672a 100644 --- a/shared/extra-utils/videos/video-abuses.ts +++ b/shared/extra-utils/videos/video-abuses.ts | |||
@@ -1,17 +1,26 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' | 2 | import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' |
3 | import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests' | 3 | import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests' |
4 | import { VideoAbuseState } from '@shared/models' | 4 | import { VideoAbuseState, VideoAbusePredefinedReasonsString } from '@shared/models' |
5 | import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type' | 5 | import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type' |
6 | 6 | ||
7 | function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) { | 7 | function reportVideoAbuse ( |
8 | url: string, | ||
9 | token: string, | ||
10 | videoId: number | string, | ||
11 | reason: string, | ||
12 | predefinedReasons?: VideoAbusePredefinedReasonsString[], | ||
13 | startAt?: number, | ||
14 | endAt?: number, | ||
15 | specialStatus = 200 | ||
16 | ) { | ||
8 | const path = '/api/v1/videos/' + videoId + '/abuse' | 17 | const path = '/api/v1/videos/' + videoId + '/abuse' |
9 | 18 | ||
10 | return request(url) | 19 | return request(url) |
11 | .post(path) | 20 | .post(path) |
12 | .set('Accept', 'application/json') | 21 | .set('Accept', 'application/json') |
13 | .set('Authorization', 'Bearer ' + token) | 22 | .set('Authorization', 'Bearer ' + token) |
14 | .send({ reason }) | 23 | .send({ reason, predefinedReasons, startAt, endAt }) |
15 | .expect(specialStatus) | 24 | .expect(specialStatus) |
16 | } | 25 | } |
17 | 26 | ||
@@ -19,6 +28,7 @@ function getVideoAbusesList (options: { | |||
19 | url: string | 28 | url: string |
20 | token: string | 29 | token: string |
21 | id?: number | 30 | id?: number |
31 | predefinedReason?: VideoAbusePredefinedReasonsString | ||
22 | search?: string | 32 | search?: string |
23 | state?: VideoAbuseState | 33 | state?: VideoAbuseState |
24 | videoIs?: VideoAbuseVideoIs | 34 | videoIs?: VideoAbuseVideoIs |
@@ -31,6 +41,7 @@ function getVideoAbusesList (options: { | |||
31 | url, | 41 | url, |
32 | token, | 42 | token, |
33 | id, | 43 | id, |
44 | predefinedReason, | ||
34 | search, | 45 | search, |
35 | state, | 46 | state, |
36 | videoIs, | 47 | videoIs, |
@@ -44,6 +55,7 @@ function getVideoAbusesList (options: { | |||
44 | const query = { | 55 | const query = { |
45 | sort: 'createdAt', | 56 | sort: 'createdAt', |
46 | id, | 57 | id, |
58 | predefinedReason, | ||
47 | search, | 59 | search, |
48 | state, | 60 | state, |
49 | videoIs, | 61 | videoIs, |