aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/server.ts')
-rw-r--r--server/middlewares/validators/server.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index 6158c3363..fe6704716 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -7,6 +7,7 @@ import { body } from 'express-validator'
7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' 7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
8import { Redis } from '../../lib/redis' 8import { Redis } from '../../lib/redis'
9import { CONFIG, isEmailEnabled } from '../../initializers/config' 9import { CONFIG, isEmailEnabled } from '../../initializers/config'
10import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
10 11
11const serverGetValidator = [ 12const serverGetValidator = [
12 body('host').custom(isHostValid).withMessage('Should have a valid host'), 13 body('host').custom(isHostValid).withMessage('Should have a valid host'),
@@ -18,9 +19,9 @@ const serverGetValidator = [
18 19
19 const server = await ServerModel.loadByHost(req.body.host) 20 const server = await ServerModel.loadByHost(req.body.host)
20 if (!server) { 21 if (!server) {
21 return res.status(404) 22 return res.status(HttpStatusCode.NOT_FOUND_404)
22 .send({ error: 'Server host not found.' }) 23 .send({ error: 'Server host not found.' })
23 .end() 24 .end()
24 } 25 }
25 26
26 res.locals.server = server 27 res.locals.server = server
@@ -44,14 +45,14 @@ const contactAdministratorValidator = [
44 45
45 if (CONFIG.CONTACT_FORM.ENABLED === false) { 46 if (CONFIG.CONTACT_FORM.ENABLED === false) {
46 return res 47 return res
47 .status(409) 48 .status(HttpStatusCode.CONFLICT_409)
48 .send({ error: 'Contact form is not enabled on this instance.' }) 49 .send({ error: 'Contact form is not enabled on this instance.' })
49 .end() 50 .end()
50 } 51 }
51 52
52 if (isEmailEnabled() === false) { 53 if (isEmailEnabled() === false) {
53 return res 54 return res
54 .status(409) 55 .status(HttpStatusCode.CONFLICT_409)
55 .send({ error: 'Emailer is not enabled on this instance.' }) 56 .send({ error: 'Emailer is not enabled on this instance.' })
56 .end() 57 .end()
57 } 58 }
@@ -60,7 +61,7 @@ const contactAdministratorValidator = [
60 logger.info('Refusing a contact form by %s: already sent one recently.', req.ip) 61 logger.info('Refusing a contact form by %s: already sent one recently.', req.ip)
61 62
62 return res 63 return res
63 .status(403) 64 .status(HttpStatusCode.FORBIDDEN_403)
64 .send({ error: 'You already sent a contact form recently.' }) 65 .send({ error: 'You already sent a contact form recently.' })
65 .end() 66 .end()
66 } 67 }