diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-10 07:18:48 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-10 07:18:48 +0100 |
| commit | 26f8a74aee3a14563d2e802b62ee70e4f4a5bcd8 (patch) | |
| tree | 5a3f83814a20f757c547e2514fed21892a012984 /bucky/app/bucky.js | |
| parent | 9e6b80c0321ba1fbe1c824083acbeeac7b7b94d4 (diff) | |
pull in old upload script
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" }) |
