3d-interface/posts/feedback-target/index.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-08-29 16:33:58 +02:00
var pg = require('pg');
var pgc = require('../../private.js');
var db = require('../../controllers/prototype/dbrequests.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 = 'id : ' + req.session.userId + '\n';
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) {
text += 'workerId : ' + result.rows[0].name + '\n';
for (var i in req.body) {
text += i + ' : ' + req.body[i] + '\n';
}
2015-08-29 16:33:58 +02:00
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');
};