diff options
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 876a769..00730c5 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -77,17 +77,30 @@ var bucky = module.exports = { return } var data = { - thread: res.thread.get('id'), - parent_id: req.body.parent_id || -1, + title: req.body.title, + keyword: req.body.keyword, username: req.user.get('username'), - date: util.now(), - comment: req.body.comment, + createdate: util.now(), + lastmodified: util.now(), + size: 0, + private: false, + color: req.body.color, + viewed: 0, + revision: 'a', } - db.createComment(data).then(function(comment){ - res.comment = comment + db.createThread(data).then(function(thread){ + res.thread = thread next() }) }, + verifyFilesOrComment: function (req, res, next){ + var hasComment = req.body.comment && req.body.comment.length + var hasFile = req.files && req.files.length + if (! hasComment && ! hasFile) { + return res.sendStatus(400) + } + next() + }, /* DETAILS */ @@ -166,6 +179,12 @@ var bucky = module.exports = { /* COMMENTS */ + createOptionalComment: function(req, res, next){ + if (! req.body.comment || ! req.body.comment.length) { + return next() + } + bucky.createComment(req, res, next) + }, createComment: function (req, res, next){ if (! req.body.comment || ! req.body.comment.length) { res.json({ error: "no comment" }) |
