mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-15 18:26:15 +01:00
feat(writeapi): post delete/restore/purge
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
const user = require('../user');
|
||||
const groups = require('../groups');
|
||||
const topics = require('../topics');
|
||||
const posts = require('../posts');
|
||||
|
||||
const helpers = require('../controllers/helpers');
|
||||
|
||||
@@ -36,4 +37,12 @@ module.exports = function (middleware) {
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
middleware.assertPost = async (req, res, next) => {
|
||||
if (!await posts.exists(req.params.pid)) {
|
||||
return helpers.formatApiResponse(404, res, new Error('[[error:no-topic]]'));
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user