summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-09-25 18:05:37 -0400
committerJules Laplace <jules@okfoc.us>2015-09-25 18:05:37 -0400
commited083ad3191a5d7d61abb21fa7dafec5121ecaab (patch)
tree46f73a62a8c8115d900221ae1b9fca7d4e662030 /bucky/app/bucky.js
parent3aa171fbaf05d0ee5b82673443da51ed43719475 (diff)
post comment
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index 43799fe..008427d 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -1,5 +1,5 @@
var db = require('../db')
-var util = require('../lib/util')
+var util = require('../util/util')
var _ = require('lodash')
var bucky = module.exports = {
@@ -136,6 +136,26 @@ var bucky = module.exports = {
})
},
+ /* COMMENTS */
+
+ createComment: function (req, res, next){
+ if (! req.body.comment || ! req.body.comment.length) {
+ res.json({ error: "no comment" })
+ return
+ }
+ var data = {
+ thread: res.thread.get('id'),
+ parent_id: req.body.parent_id || -1,
+ username: req.user.get('username'),
+ date: util.now(),
+ comment: req.body.comment,
+ }
+ db.createComment(data).then(function(comment){
+ res.comment = comment
+ next()
+ })
+ },
+
/* MAIL */
ensureMailboxes: function (req, res, next){