aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/middlewares')
-rw-r--r--server/helpers/middlewares/abuses.ts13
-rw-r--r--server/helpers/middlewares/accounts.ts4
2 files changed, 13 insertions, 4 deletions
diff --git a/server/helpers/middlewares/abuses.ts b/server/helpers/middlewares/abuses.ts
index 3906f6760..b102273a2 100644
--- a/server/helpers/middlewares/abuses.ts
+++ b/server/helpers/middlewares/abuses.ts
@@ -17,7 +17,6 @@ async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: stri
17 if (abuse === null) { 17 if (abuse === null) {
18 res.status(404) 18 res.status(404)
19 .json({ error: 'Video abuse not found' }) 19 .json({ error: 'Video abuse not found' })
20 .end()
21 20
22 return false 21 return false
23 } 22 }
@@ -26,8 +25,18 @@ async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: stri
26 return true 25 return true
27} 26}
28 27
29async function doesAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) { 28async function doesAbuseExist (abuseId: number | string, res: Response) {
29 const abuse = await AbuseModel.loadById(parseInt(abuseId + '', 10))
30 30
31 if (!abuse) {
32 res.status(404)
33 .json({ error: 'Video abuse not found' })
34
35 return false
36 }
37
38 res.locals.abuse = abuse
39 return true
31} 40}
32 41
33// --------------------------------------------------------------------------- 42// ---------------------------------------------------------------------------
diff --git a/server/helpers/middlewares/accounts.ts b/server/helpers/middlewares/accounts.ts
index bddea7eaa..29b4ed1a6 100644
--- a/server/helpers/middlewares/accounts.ts
+++ b/server/helpers/middlewares/accounts.ts
@@ -3,8 +3,8 @@ import { AccountModel } from '../../models/account/account'
3import * as Bluebird from 'bluebird' 3import * as Bluebird from 'bluebird'
4import { MAccountDefault } from '../../types/models' 4import { MAccountDefault } from '../../types/models'
5 5
6function doesAccountIdExist (id: number, res: Response, sendNotFound = true) { 6function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
7 const promise = AccountModel.load(id) 7 const promise = AccountModel.load(parseInt(id + '', 10))
8 8
9 return doesAccountExist(promise, res, sendNotFound) 9 return doesAccountExist(promise, res, sendNotFound)
10} 10}