mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
refactor: add sanity checks to sio
This commit is contained in:
@@ -5,11 +5,17 @@ const sockets = require('../index');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
SocketPosts.getVoters = async function (socket, data) {
|
||||
if (!data || !data.pid) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
sockets.warnDeprecated(socket, 'GET /api/v3/posts/:pid/voters');
|
||||
return await api.posts.getVoters(socket, { pid: data.pid });
|
||||
};
|
||||
|
||||
SocketPosts.getUpvoters = async function (socket, pids) {
|
||||
if (!Array.isArray(pids)) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
sockets.warnDeprecated(socket, 'GET /api/v3/posts/:pid/upvoters');
|
||||
return await api.posts.getUpvoters(socket, { pid: pids[0] });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user