Add server API to abuse messages

This commit is contained in:
Chocobozzz
2020-07-24 15:05:51 +02:00
committed by Chocobozzz
parent 20516920d2
commit edbc932546
28 changed files with 1054 additions and 209 deletions

View File

@@ -5,7 +5,7 @@ import { chain } from 'lodash'
import * as path from 'path'
import * as winston from 'winston'
import { AUDIT_LOG_FILENAME } from '@server/initializers/constants'
import { Abuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared'
import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared'
import { CustomConfig } from '../../shared/models/server/custom-config.model'
import { VideoComment } from '../../shared/models/videos/video-comment.model'
import { CONFIG } from '../initializers/config'
@@ -219,7 +219,7 @@ const abuseKeysToKeep = [
'createdAt'
]
class AbuseAuditView extends EntityAuditView {
constructor (private readonly abuse: Abuse) {
constructor (private readonly abuse: AdminAbuse) {
super(abuseKeysToKeep, 'abuse', abuse)
}
}

View File

@@ -4,6 +4,7 @@ import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { exists, isArray } from './misc'
const ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES
const ABUSE_MESSAGES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSE_MESSAGES
function isAbuseReasonValid (value: string) {
return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON)
@@ -46,13 +47,18 @@ function isAbuseVideoIsValid (value: AbuseVideoIs) {
)
}
function isAbuseMessageValid (value: string) {
return exists(value) && validator.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE)
}
// ---------------------------------------------------------------------------
export {
isAbuseReasonValid,
isAbuseFilterValid,
isAbusePredefinedReasonValid,
areAbusePredefinedReasonsValid as isAbusePredefinedReasonsValid,
isAbuseMessageValid,
areAbusePredefinedReasonsValid,
isAbuseTimestampValid,
isAbuseTimestampCoherent,
isAbuseModerationCommentValid,