]>
Commit | Line | Data |
---|---|---|
a4101923 C |
1 | import * as express from 'express' |
2 | import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares' | |
3 | import { Redis } from '../../../lib/redis' | |
4 | import { Emailer } from '../../../lib/emailer' | |
5 | import { ContactForm } from '../../../../shared/models/server' | |
2d53be02 | 6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
a4101923 C |
7 | |
8 | const contactRouter = express.Router() | |
9 | ||
10 | contactRouter.post('/contact', | |
11 | asyncMiddleware(contactAdministratorValidator), | |
12 | asyncMiddleware(contactAdministrator) | |
13 | ) | |
14 | ||
15 | async function contactAdministrator (req: express.Request, res: express.Response) { | |
16 | const data = req.body as ContactForm | |
17 | ||
4e9fa5b7 | 18 | await Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) |
a4101923 C |
19 | |
20 | await Redis.Instance.setContactFormIp(req.ip) | |
21 | ||
2d53be02 | 22 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
a4101923 C |
23 | } |
24 | ||
25 | // --------------------------------------------------------------------------- | |
26 | ||
27 | export { | |
28 | contactRouter | |
29 | } |