summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-10 07:02:47 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-10 07:02:47 +0100
commit9e6b80c0321ba1fbe1c824083acbeeac7b7b94d4 (patch)
tree67cd6d247cd1bc15c43ebad10e2f02249217e8ca /bucky/app/bucky.js
parenta932b664db987f2cf9ceefe9bb56e43793470d5e (diff)
post form and other stuff
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index d1aad4d..876a769 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -71,6 +71,23 @@ var bucky = module.exports = {
next()
})
},
+ createThread: function (req, res, next){
+ if (! req.body.title || ! req.body.title.length) {
+ res.json({ error: "no title" })
+ 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()
+ })
+ },
/* DETAILS */
@@ -125,6 +142,15 @@ var bucky = module.exports = {
next()
})
},
+ ensureKeywords: function (req, res, next){
+ db.getKeywords().then(function(k){
+ if (! k) {
+ return res.sendStatus(404)
+ }
+ res.keywords = k
+ next()
+ })
+ },
ensureThreadsForKeyword: function (req, res, next){
var keyword = req.params.keyword
if (! keyword) {