refactor(socket.io): deprecate categories.setWatchState in favour of api.categories.setWatchState

This commit is contained in:
Julian Lam
2023-10-23 12:11:34 -04:00
parent f1dbfaa283
commit d7c6b3d60e
7 changed files with 81 additions and 24 deletions

View File

@@ -11,6 +11,7 @@ const nconf = require('nconf');
const file = require('../file');
const user = require('../user');
const groups = require('../groups');
const categories = require('../categories');
const topics = require('../topics');
const posts = require('../posts');
const messaging = require('../messaging');
@@ -39,6 +40,14 @@ Assert.group = helpers.try(async (req, res, next) => {
next();
});
Assert.category = helpers.try(async (req, res, next) => {
if (!await categories.exists(req.params.cid)) {
return controllerHelpers.formatApiResponse(404, res, new Error('[[error:no-category]]'));
}
next();
});
Assert.topic = helpers.try(async (req, res, next) => {
if (!await topics.exists(req.params.tid)) {
return controllerHelpers.formatApiResponse(404, res, new Error('[[error:no-topic]]'));