mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
More typechecking
This commit is contained in:
@@ -25,7 +25,10 @@ function get_history(channel, all, socket) {
|
||||
|
||||
|
||||
function chat(msg, guid, offline, socket) {
|
||||
if(typeof(msg) !== 'object' && !msg.hasOwnProperty('data') && !msg.hasOwnProperty('channel') && !msg.hasOwnProperty('pass')) {
|
||||
if(typeof(msg) !== 'object' || !msg.hasOwnProperty('data') ||
|
||||
!msg.hasOwnProperty('channel') || !msg.hasOwnProperty('pass') ||
|
||||
typeof(msg.data) != "string" || typeof(msg.channel) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit('update_required');
|
||||
return;
|
||||
}
|
||||
@@ -58,7 +61,9 @@ function chat(msg, guid, offline, socket) {
|
||||
}
|
||||
|
||||
function all_chat(msg, guid, offline, socket) {
|
||||
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") || !msg.hasOwnProperty("data")) {
|
||||
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") ||
|
||||
!msg.hasOwnProperty("data") || typeof(msg.data) != "string" ||
|
||||
typeof(msg.channel) != "string") {
|
||||
socket.emit('update_required');
|
||||
return;
|
||||
}
|
||||
@@ -86,7 +91,9 @@ function all_chat(msg, guid, offline, socket) {
|
||||
}
|
||||
|
||||
function namechange(data, guid, socket, tried) {
|
||||
if(!data.hasOwnProperty("name") || data.name.length > 10 || !data.hasOwnProperty("channel")) return;
|
||||
if(!data.hasOwnProperty("name") || data.name.length > 10 ||
|
||||
!data.hasOwnProperty("channel") || typeof(msg.name) != "string" ||
|
||||
typeof(msg.channel) != "string") return;
|
||||
var pw = "";
|
||||
var new_password;
|
||||
var first = false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
function frontpage_lists(msg, socket) {
|
||||
if(msg == undefined || !msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection("frontpage_lists").find({frontpage:true}, function(err, docs){
|
||||
|
||||
@@ -46,7 +46,9 @@ module.exports = function() {
|
||||
|
||||
socket.on('chromecast', function(msg) {
|
||||
try {
|
||||
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel")) {
|
||||
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") &&
|
||||
msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" &&
|
||||
typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string") {
|
||||
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
|
||||
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
|
||||
guid = msg.guid;
|
||||
@@ -113,7 +115,8 @@ module.exports = function() {
|
||||
});
|
||||
|
||||
socket.on("offline", function(msg){
|
||||
if(!msg.hasOwnProperty('status') && !msg.hasOwnProperty('channel')) {
|
||||
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
|
||||
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
@@ -159,6 +162,11 @@ module.exports = function() {
|
||||
});
|
||||
|
||||
socket.on('get_history', function(msg) {
|
||||
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
|
||||
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
Chat.get_history(msg.channel, msg.all, socket);
|
||||
});
|
||||
|
||||
@@ -352,7 +360,8 @@ module.exports = function() {
|
||||
|
||||
socket.on('pos', function(obj)
|
||||
{
|
||||
|
||||
if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string" ||
|
||||
(obj.hasOwnProperty("pass") && typeof(obj.pass) != "string"))
|
||||
if(coll !== undefined) {
|
||||
try {
|
||||
coll = obj.channel;
|
||||
|
||||
@@ -22,8 +22,10 @@ function list(msg, guid, coll, offline, socket) {
|
||||
|
||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass'))
|
||||
{
|
||||
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
||||
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined ||
|
||||
typeof(msg.channel) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
@@ -92,7 +94,7 @@ function skip(list, guid, coll, offline, socket) {
|
||||
}
|
||||
if(typeof(list.pass) != "string" || typeof(list.id) != "string" ||
|
||||
typeof(list.channel) != "string" || typeof(list.userpass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
@@ -433,17 +435,12 @@ function end(obj, coll, guid, offline, socket) {
|
||||
|
||||
if(id !== undefined && id !== null && id !== "") {
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
if(coll == "" || coll == undefined || coll == null || typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
||||
typeof(obj.pass) != "string") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
||||
typeof(obj.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
typeof(arr.playlist) != "boolean" || typeof(arr.num) != "number" ||
|
||||
typeof(arr.total) != "number" || typeof(arr.pass) != "string" ||
|
||||
typeof(arr.adminpass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.id) != "string" ||
|
||||
typeof(msg.type) != "string" || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ function shuffle(msg, coll, guid, offline, socket) {
|
||||
|
||||
if(typeof(msg.adminpass) != "string" || typeof(msg.channel) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ function delete_all(msg, coll, guid, offline, socket) {
|
||||
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
db.collection(coll + "_settings").find(function(err, conf) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
function password(inp, coll, guid, offline, socket) {
|
||||
if(inp !== undefined && inp !== null && inp !== "")
|
||||
{
|
||||
if(!inp.hasOwnProperty("password") || !inp.hasOwnProperty("channel") ||
|
||||
typeof(inp.password) != "string" || typeof(inp.channel) != "string") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
pw = inp.password;
|
||||
opw = inp.password;
|
||||
try {
|
||||
|
||||
@@ -67,7 +67,8 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||
}
|
||||
|
||||
function check_error_video(msg, channel) {
|
||||
if(!msg.hasOwnProperty("id") || !msg.hasOwnProperty("title")) {
|
||||
if(!msg.hasOwnProperty("id") || !msg.hasOwnProperty("title") ||
|
||||
typeof(msg.id) != "string" || typeof(msg.title) != "string") {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
||||
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
||||
@@ -30,7 +30,7 @@ function description(msg, coll, guid, offline, socket) {
|
||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
var channel = msg.channel.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user