aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/shared/abuses.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-03 17:33:44 +0200
committerChocobozzz <me@florianbigard.com>2021-06-03 18:03:36 +0200
commit10363c74c1d869f0e0c7bc4d0367b1f34d1bb6a4 (patch)
tree008f8dad8032684f46105a261b27b2d6f05b36eb /server/middlewares/validators/shared/abuses.ts
parent5e08989ede1a340b9edb94465a11b1e04bf24094 (diff)
downloadPeerTube-10363c74c1d869f0e0c7bc4d0367b1f34d1bb6a4.tar.gz
PeerTube-10363c74c1d869f0e0c7bc4d0367b1f34d1bb6a4.tar.zst
PeerTube-10363c74c1d869f0e0c7bc4d0367b1f34d1bb6a4.zip
Move middleware utils in middlewares
helpers modules should not import models
Diffstat (limited to 'server/middlewares/validators/shared/abuses.ts')
-rw-r--r--server/middlewares/validators/shared/abuses.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/server/middlewares/validators/shared/abuses.ts b/server/middlewares/validators/shared/abuses.ts
new file mode 100644
index 000000000..4a20a55fa
--- /dev/null
+++ b/server/middlewares/validators/shared/abuses.ts
@@ -0,0 +1,25 @@
1import { Response } from 'express'
2import { AbuseModel } from '@server/models/abuse/abuse'
3import { HttpStatusCode } from '@shared/core-utils'
4
5async function doesAbuseExist (abuseId: number | string, res: Response) {
6 const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
7
8 if (!abuse) {
9 res.fail({
10 status: HttpStatusCode.NOT_FOUND_404,
11 message: 'Abuse not found'
12 })
13
14 return false
15 }
16
17 res.locals.abuse = abuse
18 return true
19}
20
21// ---------------------------------------------------------------------------
22
23export {
24 doesAbuseExist
25}