Refactor models (merge Players in Games), add cursor to correspondance games. Finishe...
[vchess.git] / server / routes / messages.js
... / ...
CommitLineData
1let router = require("express").Router();
2const access = require("../utils/access");
3const sendEmail = require(__dirname.replace("/routes", "/utils/mailer"));
4const params = require(__dirname.replace("/routes", "/config/parameters"));
5
6// Send a message through contact form
7router.post("/messages", access.ajax, (req,res) => {
8 const from = req.body["email"];
9 // Replace potential newline characters in subject
10 const subject = req.body["subject"].replace(/\r?\n|\r/g, " ");
11 const body = req.body["content"];
12
13 sendEmail(from, params.mail.contact, subject, body, err => {
14 res.json(err || {});
15 });
16});
17
18module.exports = router;