summaryrefslogtreecommitdiff
path: root/lib/router.js
diff options
context:
space:
mode:
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
})