From edbc9325462ddf4536775871ebc25e06f46612d1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 24 Jul 2020 15:05:51 +0200 Subject: Add server API to abuse messages --- server/helpers/audit-logger.ts | 4 ++-- server/helpers/custom-validators/abuses.ts | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index 954b0b69d..6aae5e821 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts @@ -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) } } diff --git a/server/helpers/custom-validators/abuses.ts b/server/helpers/custom-validators/abuses.ts index 0ca06a252..0ddde4b06 100644 --- a/server/helpers/custom-validators/abuses.ts +++ b/server/helpers/custom-validators/abuses.ts @@ -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, -- cgit v1.2.3