From 0b5e74430f688aa08d374966d39b7281e9b064cc Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 24 Apr 2020 11:04:44 +0200 Subject: bury thread api --- bucky/app/api.js | 10 ++++++++++ bucky/app/bucky.js | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'bucky') diff --git a/bucky/app/api.js b/bucky/app/api.js index 11ced51..8840fa0 100644 --- a/bucky/app/api.js +++ b/bucky/app/api.js @@ -166,6 +166,16 @@ function route (app){ function(req, res){ res.send({ status: 'ok' }) }) + app.get("/api/thread/:id/bury", + middleware.ensureAuthenticated, + bucky.ensureThread, + privacy.checkThreadPrivacy, + bucky.buryThread, + function(req, res){ + res.json({ + thread: res.thread, + }) + }) /* comments */ diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 74caa66..47e8d26 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -179,6 +179,10 @@ var bucky = module.exports = { next() }) }, + buryThread: function (req, res, next){ + res.thread.set('lastmodified', util.now() - (14 * 86400 * 1000)) + res.thread.save().then( () => next() ) + }, bumpViewCount: function(req, res, next) { res.thread.set('viewed', res.thread.get('viewed') + 1) -- cgit v1.2.3-70-g09d2