diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-08 15:51:46 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-10 14:02:41 +0200 |
commit | 310b5219b38427f0c2c7ba57225afdd8f3064380 (patch) | |
tree | 853ff7e4e66425ca47b0999384eeb08ed14b28ff /server/helpers | |
parent | 811cef146c841ef8530bc812c05dfee77e0f2998 (diff) | |
download | PeerTube-310b5219b38427f0c2c7ba57225afdd8f3064380.tar.gz PeerTube-310b5219b38427f0c2c7ba57225afdd8f3064380.tar.zst PeerTube-310b5219b38427f0c2c7ba57225afdd8f3064380.zip |
Add new abuses tests
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/abuses.ts | 6 | ||||
-rw-r--r-- | server/helpers/custom-validators/video-comments.ts | 4 | ||||
-rw-r--r-- | server/helpers/middlewares/abuses.ts | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/server/helpers/custom-validators/abuses.ts b/server/helpers/custom-validators/abuses.ts index c21468caa..0ca06a252 100644 --- a/server/helpers/custom-validators/abuses.ts +++ b/server/helpers/custom-validators/abuses.ts | |||
@@ -3,10 +3,10 @@ import { AbuseFilter, abusePredefinedReasonsMap, AbusePredefinedReasonsString, A | |||
3 | import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' | 3 | import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' |
4 | import { exists, isArray } from './misc' | 4 | import { exists, isArray } from './misc' |
5 | 5 | ||
6 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES | 6 | const ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES |
7 | 7 | ||
8 | function isAbuseReasonValid (value: string) { | 8 | function isAbuseReasonValid (value: string) { |
9 | return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON) | 9 | return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON) |
10 | } | 10 | } |
11 | 11 | ||
12 | function isAbusePredefinedReasonValid (value: AbusePredefinedReasonsString) { | 12 | function isAbusePredefinedReasonValid (value: AbusePredefinedReasonsString) { |
@@ -32,7 +32,7 @@ function isAbuseTimestampCoherent (endAt: number, { req }) { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | function isAbuseModerationCommentValid (value: string) { | 34 | function isAbuseModerationCommentValid (value: string) { |
35 | return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT) | 35 | return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT) |
36 | } | 36 | } |
37 | 37 | ||
38 | function isAbuseStateValid (value: string) { | 38 | function isAbuseStateValid (value: string) { |
diff --git a/server/helpers/custom-validators/video-comments.ts b/server/helpers/custom-validators/video-comments.ts index a01680cbe..455ff4241 100644 --- a/server/helpers/custom-validators/video-comments.ts +++ b/server/helpers/custom-validators/video-comments.ts | |||
@@ -68,7 +68,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r | |||
68 | 68 | ||
69 | async function doesCommentIdExist (idArg: number | string, res: express.Response) { | 69 | async function doesCommentIdExist (idArg: number | string, res: express.Response) { |
70 | const id = parseInt(idArg + '', 10) | 70 | const id = parseInt(idArg + '', 10) |
71 | const videoComment = await VideoCommentModel.loadById(id) | 71 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) |
72 | 72 | ||
73 | if (!videoComment) { | 73 | if (!videoComment) { |
74 | res.status(404) | 74 | res.status(404) |
@@ -77,7 +77,7 @@ async function doesCommentIdExist (idArg: number | string, res: express.Response | |||
77 | return false | 77 | return false |
78 | } | 78 | } |
79 | 79 | ||
80 | res.locals.videoComment = videoComment | 80 | res.locals.videoCommentFull = videoComment |
81 | 81 | ||
82 | return true | 82 | return true |
83 | } | 83 | } |
diff --git a/server/helpers/middlewares/abuses.ts b/server/helpers/middlewares/abuses.ts index b102273a2..be8c8b449 100644 --- a/server/helpers/middlewares/abuses.ts +++ b/server/helpers/middlewares/abuses.ts | |||
@@ -30,7 +30,7 @@ async function doesAbuseExist (abuseId: number | string, res: Response) { | |||
30 | 30 | ||
31 | if (!abuse) { | 31 | if (!abuse) { |
32 | res.status(404) | 32 | res.status(404) |
33 | .json({ error: 'Video abuse not found' }) | 33 | .json({ error: 'Abuse not found' }) |
34 | 34 | ||
35 | return false | 35 | return false |
36 | } | 36 | } |