From e4e0cf21a31b74d5ee1e6d45b343ea60ed44f372 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 8 Dec 2017 01:35:26 +0100 Subject: hootbox stuff --- lib/router.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/router.js') diff --git a/lib/router.js b/lib/router.js index 4451a13..c08037e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2,6 +2,7 @@ var auth = require('./auth') var middleware = require('./middleware') var fortune = require('./fortune') var bucky = require('./bucky') +var db = require('./db') var util = require('./util') module.exports = function(app){ @@ -66,6 +67,24 @@ module.exports = function(app){ }) app.post("/api/thread/:id/comment", middleware.ensureAuthenticated, + bucky.ensureThread, + function(req, res){ + if (!req.params.id) return res.sendStatus(500) + var comment = { + thread: req.params.id, + parent_id: req.body.parent_id || -1, + username: req.user.get('username'), + date: Math.round(+(new Date) / 1000), + comment: req.body.comment, + hidden: false, + } + db.createComment(comment).then(function(c){ + res.json(comment) + }) + }) + app.post("/api/thread/:id/file", + middleware.ensureAuthenticated, + bucky.ensureThread, function(req, res){ // add comments and files }) -- cgit v1.2.3-70-g09d2