Node.js based forum software built for the modern web
refactor: add sanity checks to sio
Barış Soner Uşaklıe98f184868a7
diff --git a/src/socket.io/posts/votes.js b/src/socket.io/posts/votes.jsindex a7426e49ba..3a92360535 100644--- a/src/socket.io/posts/votes.js+++ b/src/socket.io/posts/votes.js@@ -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] });};