mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
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
This commit is contained in:
parent
07aea1a264
commit
1ebddadd07
35 changed files with 658 additions and 96 deletions
|
@ -1,8 +1,9 @@
|
|||
import validator from 'validator'
|
||||
|
||||
import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
|
||||
import { exists } from './misc'
|
||||
import { exists, isArray } from './misc'
|
||||
import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type'
|
||||
import { VideoAbusePredefinedReasonsString, videoAbusePredefinedReasonsMap } from '@shared/models/videos/abuse/video-abuse-reason.model'
|
||||
|
||||
const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
|
||||
|
||||
|
@ -10,6 +11,22 @@ function isVideoAbuseReasonValid (value: string) {
|
|||
return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON)
|
||||
}
|
||||
|
||||
function isVideoAbusePredefinedReasonValid (value: VideoAbusePredefinedReasonsString) {
|
||||
return exists(value) && value in videoAbusePredefinedReasonsMap
|
||||
}
|
||||
|
||||
function isVideoAbusePredefinedReasonsValid (value: VideoAbusePredefinedReasonsString[]) {
|
||||
return exists(value) && isArray(value) && value.every(v => v in videoAbusePredefinedReasonsMap)
|
||||
}
|
||||
|
||||
function isVideoAbuseTimestampValid (value: number) {
|
||||
return value === null || (exists(value) && validator.isInt('' + value, { min: 0 }))
|
||||
}
|
||||
|
||||
function isVideoAbuseTimestampCoherent (endAt: number, { req }) {
|
||||
return exists(req.body.startAt) && endAt > req.body.startAt
|
||||
}
|
||||
|
||||
function isVideoAbuseModerationCommentValid (value: string) {
|
||||
return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT)
|
||||
}
|
||||
|
@ -28,8 +45,12 @@ function isAbuseVideoIsValid (value: VideoAbuseVideoIs) {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
isVideoAbuseStateValid,
|
||||
isVideoAbuseReasonValid,
|
||||
isAbuseVideoIsValid,
|
||||
isVideoAbuseModerationCommentValid
|
||||
isVideoAbusePredefinedReasonValid,
|
||||
isVideoAbusePredefinedReasonsValid,
|
||||
isVideoAbuseTimestampValid,
|
||||
isVideoAbuseTimestampCoherent,
|
||||
isVideoAbuseModerationCommentValid,
|
||||
isVideoAbuseStateValid,
|
||||
isAbuseVideoIsValid
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue