From a2e7bb7ffb472d8e4a3118a765ca3489f2b58e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 12 Sep 2017 20:19:13 +0200 Subject: [PATCH] Updated socket.id for chromecastlistening on mobile --- server/handlers/io.js | 4 +++- server/handlers/list.js | 4 ++-- server/handlers/list_change.js | 8 ++++---- server/handlers/list_settings.js | 8 ++++---- server/handlers/suggestions.js | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index da724343..ed81cca1 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -1,5 +1,6 @@ module.exports = function() { io.on('connection', function(socket){ + socket.zoff_id = socket.id; socket.emit("get_list"); var guid = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); @@ -14,7 +15,7 @@ module.exports = function() { - var socketid = socket.id; + var socketid = socket.zoff_id; var coll; var in_list = false; var short_id; @@ -44,6 +45,7 @@ module.exports = function() { if(connected_users_channel.users.indexOf(msg.guid) > -1) { guid = msg.guid; socketid = msg.socket_id; + socket.zoff_id = socketid; coll = msg.channel; in_list = true; chromecast_object = true; diff --git a/server/handlers/list.js b/server/handlers/list.js index e81b3f6e..e1d683cb 100644 --- a/server/handlers/list.js +++ b/server/handlers/list.js @@ -16,7 +16,7 @@ var now_playing = function(list, fn, socket) { } var list = function(msg, guid, coll, offline, socket) { - var socketid = socket.id; + var socketid = socket.zoff_id; if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass')) { @@ -68,7 +68,7 @@ var list = function(msg, guid, coll, offline, socket) { } var skip = function(list, guid, coll, offline, socket) { - var socketid = socket.id; + var socketid = socket.zoff_id; if(list !== undefined && list !== null && list !== "") { diff --git a/server/handlers/list_change.js b/server/handlers/list_change.js index 356cfc38..86040d79 100644 --- a/server/handlers/list_change.js +++ b/server/handlers/list_change.js @@ -1,5 +1,5 @@ var add = function(arr, coll, guid, offline, socket) { - var socketid = socket.id; + var socketid = socket.zoff_id; if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration))) { @@ -146,7 +146,7 @@ var add = function(arr, coll, guid, offline, socket) { } var voteUndecided = function(msg, coll, guid, offline, socket) { - var socketid = socket.id; + var socketid = socket.zoff_id; if(typeof(msg) === 'object' && msg !== undefined && msg !== null){ if(coll == "" || coll == undefined || coll == null || !msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("pass") || !msg.hasOwnProperty("id")) { @@ -185,7 +185,7 @@ var voteUndecided = function(msg, coll, guid, offline, socket) { } var shuffle = function(msg, coll, guid, offline, socket) { - var socketid = socket.id; + var socketid = socket.zoff_id; if(msg.hasOwnProperty('adminpass') && msg.adminpass !== undefined && msg.adminpass !== null) { if(coll == "" || coll == undefined || coll == null) { @@ -260,7 +260,7 @@ function del(params, socket, socketid) { } var delete_all = function(msg, coll, guid, offline, socket) { - var socketid = socket.id; + var socketid = socket.zoff_id; if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) { var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass)); var hash_userpass = Functions.decrypt_string(socketid, msg.pass); diff --git a/server/handlers/list_settings.js b/server/handlers/list_settings.js index f7f677f4..380d8ef7 100644 --- a/server/handlers/list_settings.js +++ b/server/handlers/list_settings.js @@ -20,7 +20,7 @@ var password = function(inp, coll, guid, offline, socket) { } uncrypted = pw; - pw = Functions.decrypt_string(socket.id, pw); + pw = Functions.decrypt_string(socket.zoff_id, pw); Functions.check_inlist(coll, guid, socket, offline); @@ -28,7 +28,7 @@ var password = function(inp, coll, guid, offline, socket) { { opw = inp.oldpass; } - opw = Functions.decrypt_string(socket.id, opw); + opw = Functions.decrypt_string(socket.zoff_id, opw); db.collection(coll).find({views:{$exists:true}}, function(err, docs){ if(docs !== null && docs.length !== 0) @@ -93,7 +93,7 @@ var conf = function(params, coll, guid, offline, socket) { var adminpass = params.adminpass; var skipping = params.skipping; var shuffling = params.shuffling; - var userpass = Functions.decrypt_string(socket.id, params.userpass); + var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass); if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) { userpass = ""; @@ -105,7 +105,7 @@ var conf = function(params, coll, guid, offline, socket) { if(params.description) description = params.description; if(adminpass !== "") { - hash = Functions.hash_pass(Functions.decrypt_string(socket.id, adminpass)); + hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, adminpass)); } else { hash = adminpass; } diff --git a/server/handlers/suggestions.js b/server/handlers/suggestions.js index a09faa35..c817ea14 100644 --- a/server/handlers/suggestions.js +++ b/server/handlers/suggestions.js @@ -3,7 +3,7 @@ var thumbnail = function(msg, coll, guid, offline, socket) { msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, ""); if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail; var channel = msg.channel.toLowerCase(); - var hash = Functions.hash_pass(Functions.decrypt_string(socket.id, msg.adminpass)); + var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass)); db.collection(channel).find({views:{$exists:true}}, function(err, docs){ if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) { if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){ @@ -23,7 +23,7 @@ var thumbnail = function(msg, coll, guid, offline, socket) { var description = function(msg, coll, guid, offline, socket) { if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){ var channel = msg.channel.toLowerCase(); - var hash = Functions.hash_pass(Functions.decrypt_string(socket.id, msg.adminpass)); + var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass)); db.collection(channel).find({views:{$exists:true}}, function(err, docs){ if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) { if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){