mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-17 01:50:48 +01:00
refactor(socket.io): deprecate categories.setWatchState in favour of api.categories.setWatchState
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const categories = require('../../categories');
|
||||
const meta = require('../../meta');
|
||||
const api = require('../../api');
|
||||
|
||||
const helpers = require('../helpers');
|
||||
@@ -44,6 +45,24 @@ Categories.getPosts = async (req, res) => {
|
||||
helpers.formatApiResponse(200, res, posts);
|
||||
};
|
||||
|
||||
Categories.setWatchState = async (req, res) => {
|
||||
const { cid } = req.params;
|
||||
let { uid, state } = req.body;
|
||||
|
||||
if (req.method === 'DELETE') {
|
||||
// DELETE is always setting state to system default in acp
|
||||
state = categories.watchStates[meta.config.categoryWatchState];
|
||||
} else if (Object.keys(categories.watchStates).includes(state)) {
|
||||
state = categories.watchStates[state]; // convert to integer for backend processing
|
||||
} else {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
|
||||
const { cids: modified } = await api.categories.setWatchState(req, { cid, state, uid });
|
||||
|
||||
helpers.formatApiResponse(200, res, { modified });
|
||||
};
|
||||
|
||||
Categories.getPrivileges = async (req, res) => {
|
||||
const privilegeSet = await api.categories.getPrivileges(req, { cid: req.params.cid });
|
||||
helpers.formatApiResponse(200, res, privilegeSet);
|
||||
|
||||
Reference in New Issue
Block a user