diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-15 02:43:51 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-15 02:43:51 +0100 |
| commit | 1466563673ffe6c41ec9a18bf98565b8562ee4f3 (patch) | |
| tree | 1eb576380877d3231910ccbb634f33906210ab3f /bucky/app | |
| parent | 0541e7d7457d646dceca375b7fa6e1f382232772 (diff) | |
thread_users hackery
Diffstat (limited to 'bucky/app')
| -rw-r--r-- | bucky/app/bucky.js | 20 | ||||
| -rw-r--r-- | bucky/app/router.js | 15 |
2 files changed, 34 insertions, 1 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index cf74ec2..1b14f43 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -201,7 +201,25 @@ var bucky = module.exports = { res.thread.set('settings', settings) res.thread.save().then( () => next() ) }, - + ensureInterestedUsers: function(req, res, next){ + // given a thread, find people who might be interested in it + // - other people who have been in threads with you + // - other people who have posted on the keyword + // for now though, just show the last 20 people who have logged in.. + db.getLastlog(21).then( (users) => { + res.interestedUsers = users + next() + }).catch( () => { + res.interestedUsers = [] + next() + }) + }, + ensureThreadUsers: function(req, res, next) { + db.getThreadUsers(res.thread.get('id')).then(thread_users => { + res.thread_users = thread_users + next() + }) + }, destroyThread: function (req, res, next) { console.log(">>> destroying thread", res.thread.get('id')) var commentPromises = res.comments.map((comment) => { diff --git a/bucky/app/router.js b/bucky/app/router.js index 7e13cd6..cb90350 100644 --- a/bucky/app/router.js +++ b/bucky/app/router.js @@ -97,6 +97,7 @@ module.exports = function(app){ bucky.ensureLastlog, middleware.ensureAuthenticated, bucky.ensureLatestThreads, + bucky.ensureThreadsPrivacy, bucky.ensureCommentCountsForThreads, bucky.ensureFileCountsForThreads, bucky.ensureKeywordsForThreads, @@ -113,6 +114,7 @@ module.exports = function(app){ bucky.ensureLastlog, middleware.ensureAuthenticated, bucky.ensureThreadsForKeyword, + bucky.ensureThreadsPrivacy, bucky.ensureCommentCountsForThreads, bucky.ensureFileCountsForThreads, bucky.ensureKeywordsForThreads, @@ -125,6 +127,17 @@ module.exports = function(app){ lastlog: res.lastlog, }) }) + // app.get("/api/thread/:id/interested", + // middleware.ensureAuthenticated, + // bucky.ensureThread, + // bucky.ensureThreadPrivacy, + // bucky.ensureInterestedUsers, + // // bucky.ensureThreadUsers, + // function(req, res){ + // res.json({ + // interestedUsers: res.interestedUsers, + // }) + // }) app.get("/api/thread/:id", middleware.ensureAuthenticated, bucky.ensureThread, @@ -132,11 +145,13 @@ module.exports = function(app){ bucky.ensureKeywordForThread, bucky.ensureCommentsForThread, bucky.ensureFilesForThread, + // bucky.ensureThreadUsers, bucky.prepareThread, bucky.bumpLastSeen, function(req, res){ res.json({ thread: res.thread, + thread_users: res.thread, comments: res.comments, files: res.files, keyword: res.keyword, |
