summaryrefslogtreecommitdiff
path: root/lib/router.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-08 01:35:26 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-08 01:35:26 +0100
commite4e0cf21a31b74d5ee1e6d45b343ea60ed44f372 (patch)
treed6e3d14c4b5ddfed5d8bd036a5eba29af505553b /lib/router.js
parent3a4f027ec05aa5fdf4098ceb0dab09f69c5e0b8b (diff)
hootbox stuff
Diffstat (limited to 'lib/router.js')
-rw-r--r--lib/router.js19
1 files changed, 19 insertions, 0 deletions
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
})