summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-10-02 16:48:36 +0200
committerJules Laplace <julescarbon@gmail.com>2018-10-02 16:48:36 +0200
commit501606df8254d833d05aa191a8ac180f7d508786 (patch)
tree1a88fed94fddc6525297c05264141341c3397e06
parent2a17aa1331b1e7754a1a374ed285ac0e9def9af3 (diff)
fix thread id lol omg so functional
-rw-r--r--bucky/app/site.js2
-rw-r--r--bucky/util/federate.js14
2 files changed, 7 insertions, 9 deletions
diff --git a/bucky/app/site.js b/bucky/app/site.js
index 5fa044e..e266716 100644
--- a/bucky/app/site.js
+++ b/bucky/app/site.js
@@ -57,7 +57,7 @@ site.init = function(){
}
app.use(session(sessionSettings))
upload.init()
- // federate.route(app)
+ federate.route(app)
// app.use(csurf({
// cookie: true,
diff --git a/bucky/util/federate.js b/bucky/util/federate.js
index 5181d85..605d8d2 100644
--- a/bucky/util/federate.js
+++ b/bucky/util/federate.js
@@ -34,23 +34,21 @@ module.exports = {
req.params.keyword
).then(keyword => send("keyword", keyword)
).then(res => db.getThreadsForKeyword(req.params.keyword)
- ).then(threads => threads.reduce((promise, thread) => (
- promise.then(result => exportThread({ params: { id: thread.get('id') } }, res, function(){}))
- ), new Promise (resolve => resolve()))
- ).then(() => next())
+ ).then(threads => Promise.all(threads.map(thread => exportThread({ params: { id: thread.get('id') } }, res, function(){}))
+ )).then(() => next())
}
function exportThread (req, res, next) {
- var thread_id
+ let thread_id = 0
return db.getThread(
req.params.id
-
).then(thread => send("thread", thread)
).then(json => {
console.log('got thread id', json.el.id)
+ thread_id = json.el.id
return db.getCommentsForThread(req.params.id)
}).then(comments => comments.reduce((promise, comment) => (
- promise.then(result => {
+ promise.then(res => {
comment.set('thread', thread_id)
return send("comment", comment)
})
@@ -58,7 +56,7 @@ module.exports = {
).then(() => db.getFilesForThread(req.params.id)
).then(files => files.reduce((promise, file) => (
- promise.then(result => {
+ promise.then(res => {
copyFileToS3(file, thread_id)
file.set('thread', thread_id)
file.set('storage', process.env.S3_BUCKET)