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