2015-08-29 16:33:58 +02:00
|
|
|
var pg = require('pg');
|
|
|
|
var pgc = require('../../private.js');
|
2015-07-29 11:04:38 +02:00
|
|
|
var mail = require('../../lib/mail.js');
|
|
|
|
var Log = require('../../lib/NodeLog.js');
|
|
|
|
|
|
|
|
module.exports.index = function(req, res) {
|
|
|
|
|
|
|
|
var text = '';
|
|
|
|
|
|
|
|
for (var i in req.body) {
|
2015-08-25 14:03:01 +02:00
|
|
|
text += i + ' : ' + req.body[i] + '\n';
|
2015-07-29 11:04:38 +02:00
|
|
|
}
|
|
|
|
|
2015-08-29 16:33:58 +02:00
|
|
|
pg.connect(pgc.url, function(err, client, release) {
|
|
|
|
|
|
|
|
client.query(
|
|
|
|
'SELECT Users.worker_id AS name FROM Users WHERE Users.id = $1;',
|
|
|
|
[req.session.userId],
|
|
|
|
|
|
|
|
function(err, result) {
|
|
|
|
mail.send({
|
|
|
|
from: result.rows[0].name + " <" + req.session.userId + "@toto.tata>",
|
|
|
|
to: "Thomas <dragonrock.django@gmail.com>",
|
|
|
|
subject: "By " + result.rows[0].name,
|
|
|
|
text: text
|
|
|
|
}, function(err, message) {
|
|
|
|
if (err !== null) {
|
|
|
|
Log.mailerror(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2015-07-29 11:04:38 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
res.redirect('/thankyou');
|
|
|
|
|
|
|
|
};
|