Add feedback route

This commit is contained in:
Johannes Zellner
2015-08-04 14:31:40 +02:00
parent 57e2803bd2
commit da48e32bcc
4 changed files with 44 additions and 5 deletions
+24 -1
View File
@@ -15,7 +15,11 @@ exports = module.exports = {
sendCrashNotification: sendCrashNotification,
appDied: appDied
appDied: appDied,
FEEDBACK_TYPE_FEEDBACK: 'feedback',
FEEDBACK_TYPE_TICKET: 'ticket',
sendFeedback: sendFeedback
};
var assert = require('assert'),
@@ -277,3 +281,22 @@ function sendCrashNotification(program, context) {
enqueue(mailOptions);
}
function sendFeedback(user, type, subject, description, callback) {
assert.strictEqual(typeof user, 'object');
assert.strictEqual(typeof type, 'string');
assert.strictEqual(typeof subject, 'string');
assert.strictEqual(typeof description, 'string');
assert.strictEqual(typeof callback, 'function');
assert(type === exports.FEEDBACK_TYPE_TICKET || type === exports.FEEDBACK_TYPE_FEEDBACK);
var mailOptions = {
from: config.get('adminEmail'),
to: 'johannes@cloudron.io',
subject: util.format('[%s] %s - %s', type, config.fqdn(), subject),
text: render('feedback.ejs', { fqdn: config.fqdn(), adminEmail: config.get('adminEmail'), type: type, user: user, subject: subject, description: description})
};
enqueue(mailOptions);
}