Barış Soner Uşaklı 7 years ago
parent b6562325a4
commit 5da24b4120

@ -7,7 +7,7 @@ var utils = require('../../utils');
module.exports = function (SocketTopics) { module.exports = function (SocketTopics) {
SocketTopics.isTagAllowed = function (socket, data, callback) { SocketTopics.isTagAllowed = function (socket, data, callback) {
if (!data || !data.cid || !data.tag) { if (!data || !utils.isNumber(data.cid) || !data.tag) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));
} }
async.waterfall([ async.waterfall([
@ -15,10 +15,7 @@ module.exports = function (SocketTopics) {
db.getSortedSetRange('cid:' + data.cid + ':tag:whitelist', 0, -1, next); db.getSortedSetRange('cid:' + data.cid + ':tag:whitelist', 0, -1, next);
}, },
function (tagWhitelist, next) { function (tagWhitelist, next) {
if (!tagWhitelist.length) { next(null, !tagWhitelist.length || tagWhitelist.includes(data.tag));
return next(null, true);
}
next(null, tagWhitelist.indexOf(data.tag) !== -1);
}, },
], callback); ], callback);
}; };

Loading…
Cancel
Save