]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/controllers/api/server/contact.ts
Add new plugin/peertube version notifs
[github/Chocobozzz/PeerTube.git] / server / controllers / api / server / contact.ts
CommitLineData
a4101923
C
1import * as express from 'express'
2import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares'
3import { Redis } from '../../../lib/redis'
4import { Emailer } from '../../../lib/emailer'
5import { ContactForm } from '../../../../shared/models/server'
2d53be02 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
a4101923
C
7
8const contactRouter = express.Router()
9
10contactRouter.post('/contact',
11 asyncMiddleware(contactAdministratorValidator),
12 asyncMiddleware(contactAdministrator)
13)
14
15async 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
27export {
28 contactRouter
29}