summaryrefslogtreecommitdiff
path: root/lib/bucky.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bucky.js')
-rw-r--r--lib/bucky.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/bucky.js b/lib/bucky.js
index 997d680..742f74d 100644
--- a/lib/bucky.js
+++ b/lib/bucky.js
@@ -70,6 +70,9 @@ var bucky = module.exports = {
ensureThread: function (req, res, next){
var id = req.params.id.replace(/\D/g, "")
+ if (! id) {
+ return res.sendStatus(404)
+ }
db.getThread(id).then(function(thread){
if (thread) {
res.thread = thread
@@ -106,7 +109,7 @@ var bucky = module.exports = {
ensureKeyword: function (req, res, next){
var keyword = req.params.keyword
if (! keyword) {
- res.sendStatus(404)
+ return res.sendStatus(404)
}
db.getKeyword(keyword).then(function(k){
if (! k) {
@@ -128,5 +131,32 @@ var bucky = module.exports = {
next()
})
},
+
+ /* MAIL */
+ ensureMailbox: function (req, res, next){
+ var box = req.params.box
+ if (! box) {
+ res.sendStatus(404)
+ }
+ db.getMailbox(req.user.username, box).then(function(box){
+ if (! box) {
+ return res.sendStatus(404)
+ }
+ next()
+ })
+ },
+ ensureMailboxCounts: function (req, res, next){
+ db.getMailboxes(req.user.username).then(function(boxes){
+ res.boxes = boxes
+ next()
+ })
+ },
+ ensureMessages: function (req, res, next){
+ // todo: define offset
+ db.getMessages(req.user.username, req.params.box, 50, 0).then(function(messages){
+ res.messages = messages
+ next()
+ })
+ },
} \ No newline at end of file