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

View File

@@ -11,7 +11,8 @@ exports = module.exports = {
getConfig: getConfig,
update: update,
migrate: migrate,
setCertificate: setCertificate
setCertificate: setCertificate,
feedback: feedback
};
var assert = require('assert'),
@@ -157,3 +158,16 @@ function setCertificate(req, res, next) {
next(new HttpSuccess(202, {}));
});
}
function feedback(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
if (typeof req.body.type !== 'string') return next(new HttpError(400, 'type must be either "ticket" or "feedback"'));
if (typeof req.body.subject !== 'string') return next(new HttpError(400, 'subject must be string'));
if (typeof req.body.description !== 'string') return next(new HttpError(400, 'description must be string'));
cloudron.feedback(req.user, req.body.type, req.body.subject, req.body.description, function (error) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(201, {}));
});
}