From 54b745ec68046db0d888451962024807190adfaa Mon Sep 17 00:00:00 2001 From: Alf Hammerseth Date: Sat, 16 Nov 2019 17:19:14 +0100 Subject: [PATCH] Add even more cleanup --- gulpfile.js | 202 +++++++++++++++---------------- server/handlers/chat.js | 13 +- server/handlers/db.js | 4 - server/handlers/frontpage.js | 1 - server/handlers/functions.js | 18 +-- server/handlers/io.js | 86 ++----------- server/handlers/list.js | 30 +---- server/handlers/list_change.js | 30 +---- server/handlers/list_settings.js | 9 +- server/handlers/notifications.js | 4 +- server/handlers/suggestions.js | 19 +-- 11 files changed, 129 insertions(+), 287 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 7b9134ce..4fe0bb91 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,10 +1,9 @@ var gulp = require("gulp"), uglify = require("gulp-uglify"), - //sourcemaps = require('gulp-sourcemaps'), concat = require("gulp-concat"), cleanCSS = require("gulp-clean-css"); -gulp.task("css", function() { +gulp.task("css", function () { return gulp .src([ "server/public/assets/css/style.css", @@ -13,113 +12,109 @@ gulp.task("css", function() { "server/public/assets/css/mobile.css" ]) .pipe(concat("style.css")) - .pipe(cleanCSS({ compatibility: "ie8" })) + .pipe(cleanCSS({ + compatibility: "ie8" + })) .pipe(gulp.dest("server/public/assets/dist")); }); -gulp.task("css-embed", function() { +gulp.task("css-embed", function () { return gulp .src("server/public/assets/css/embed.css") - .pipe(cleanCSS({ compatibility: "ie8" })) + .pipe(cleanCSS({ + compatibility: "ie8" + })) .pipe(gulp.dest("server/public/assets/dist")); }); -gulp.task("js", function() { +gulp.task("js", function () { return ( gulp - .src([ - "server/VERSION.js", - "server/config/api_key.js", - "server/public/assets/js/*.js", - "!server/public/assets/js/embed*", - "!server/public/assets/js/token*", - "!server/public/assets/js/remotecontroller.js", - "!server/public/assets/js/callback.js" - ]) - //.pipe(sourcemaps.init()) - .pipe(concat("main.min.js")) - .pipe( - uglify({ - mangle: true, - compress: true, - enclose: true - }) - ) - //.pipe(sourcemaps.write('maps')) - .pipe(gulp.dest("server/public/assets/dist")) + .src([ + "server/VERSION.js", + "server/config/api_key.js", + "server/public/assets/js/*.js", + "!server/public/assets/js/embed*", + "!server/public/assets/js/token*", + "!server/public/assets/js/remotecontroller.js", + "!server/public/assets/js/callback.js" + ]) + .pipe(concat("main.min.js")) + .pipe( + uglify({ + mangle: true, + compress: true, + enclose: true + }) + ) + .pipe(gulp.dest("server/public/assets/dist")) ); }); -gulp.task("embed", function() { +gulp.task("embed", function () { return ( gulp - .src([ - "server/VERSION.js", - "server/config/api_key.js", - "server/public/assets/js/player.js", - "server/public/assets/js/functions.js", - "server/public/assets/js/helpers.js", - "server/public/assets/js/playercontrols.js", - "server/public/assets/js/list.js", - "server/public/assets/js/embed.js", - "!server/public/assets/js/frontpage*", - "!server/public/assets/js/remotecontroller.js", - "server/public/assets/js/hostcontroller.js" - ]) - //.pipe(sourcemaps.init()) - .pipe(concat("embed.min.js")) - .pipe( - uglify({ - mangle: true, - compress: true, - enclose: true - }) - ) - //.pipe(sourcemaps.write('maps')) - .pipe(gulp.dest("server/public/assets/dist")) + .src([ + "server/VERSION.js", + "server/config/api_key.js", + "server/public/assets/js/player.js", + "server/public/assets/js/functions.js", + "server/public/assets/js/helpers.js", + "server/public/assets/js/playercontrols.js", + "server/public/assets/js/list.js", + "server/public/assets/js/embed.js", + "!server/public/assets/js/frontpage*", + "!server/public/assets/js/remotecontroller.js", + "server/public/assets/js/hostcontroller.js" + ]) + .pipe(concat("embed.min.js")) + .pipe( + uglify({ + mangle: true, + compress: true, + enclose: true + }) + ) + .pipe(gulp.dest("server/public/assets/dist")) ); }); -gulp.task("token", function() { +gulp.task("token", function () { return ( gulp - .src([ - "server/public/assets/js/token*", - "server/public/assets/js/helpers.js" - ]) - //.pipe(sourcemaps.init()) - .pipe(concat("token.min.js")) - .pipe( - uglify({ - mangle: true, - compress: true, - enclose: true - }) - ) - //.pipe(sourcemaps.write('maps')) - .pipe(gulp.dest("server/public/assets/dist")) + .src([ + "server/public/assets/js/token*", + "server/public/assets/js/helpers.js" + ]) + .pipe(concat("token.min.js")) + .pipe( + uglify({ + mangle: true, + compress: true, + enclose: true + }) + ) + .pipe(gulp.dest("server/public/assets/dist")) ); }); -gulp.task("callback", function() { +gulp.task("callback", function () { return ( gulp - .src([ - "server/VERSION.js", - "server/config/api_key.js", - "server/public/assets/js/callback.js" - ]) - //.pipe(sourcemaps.init()) - .pipe(concat("callback.min.js")) - .pipe( - uglify({ - mangle: true, - compress: true, - enclose: true - }) - ) - //.pipe(sourcemaps.write('maps')) - .pipe(gulp.dest("server/public/assets/dist")) + .src([ + "server/VERSION.js", + "server/config/api_key.js", + "server/public/assets/js/callback.js" + ]) + .pipe(concat("callback.min.js")) + .pipe( + uglify({ + mangle: true, + compress: true, + enclose: true + }) + ) + .pipe(gulp.dest("server/public/assets/dist")) ); }); @@ -136,30 +131,28 @@ gulp.task("build", done => { done(); }); -gulp.task("remotecontroller", function() { +gulp.task("remotecontroller", function () { return ( gulp - .src([ - "server/VERSION.js", - "server/config/api_key.js", - "server/public/assets/js/remotecontroller.js", - "server/public/assets/js/helpers.js" - ]) - ////.pipe(sourcemaps.init()) - .pipe(concat("remote.min.js")) - .pipe( - uglify({ - mangle: true, - compress: true, - enclose: true - }) - ) - //.pipe(sourcemaps.write('maps')) - .pipe(gulp.dest("server/public/assets/dist")) + .src([ + "server/VERSION.js", + "server/config/api_key.js", + "server/public/assets/js/remotecontroller.js", + "server/public/assets/js/helpers.js" + ]) + .pipe(concat("remote.min.js")) + .pipe( + uglify({ + mangle: true, + compress: true, + enclose: true + }) + ) + .pipe(gulp.dest("server/public/assets/dist")) ); }); -gulp.task("default", function() { +gulp.task("default", function () { gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["js"]); gulp.watch(["server/public/assets/css/*.css"], ["css"]); gulp.watch(["server/public/assets/css/*.css"], ["css-embed"]); @@ -176,9 +169,8 @@ gulp.task("default", function() { ], ["callback"] ); - //gulp.watch('server/public/assets/js/*.js', ['nochan']); gulp.watch( ["server/VERSION.js", "server/public/assets/js/remotecontroller.js"], ["remotecontroller"] ); -}); +}); \ No newline at end of file diff --git a/server/handlers/chat.js b/server/handlers/chat.js index b3a65d46..df22875a 100644 --- a/server/handlers/chat.js +++ b/server/handlers/chat.js @@ -14,7 +14,6 @@ function get_history(channel, all, socket) { channel: channel }; } - //channel = channel.replace(/ /g,''); var pass = ""; if (!query.all) { Functions.getSessionAdminUser( @@ -49,7 +48,6 @@ function get_history(channel, all, socket) { } function getAndSendLogs(channel, all, socket, pass, query) { - //channel = channel.replace(/ /g,''); db.collection("chat_logs") .find(query, { from: 1, @@ -108,9 +106,8 @@ function chat(msg, guid, offline, socket) { socket.emit("update_required", result); return; } - var coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + var coll = msg.channel.toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); checkIfUserIsBanned(coll, socket, guid, function () { Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( @@ -379,10 +376,9 @@ function all_chat(msg, guid, offline, socket) { socket.emit("update_required", result); return; } - var coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + var coll = msg.channel.toLowerCase(); var data = msg.data; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); Functions.check_inlist( coll, guid, @@ -481,8 +477,7 @@ function checkIfUserIsBanned(channel, socket, guid, callback, callback_error) { else { db.collection("user_names").findAndModify({ query: { - guid, - guid + guid: guid }, update: { $addToSet: { @@ -685,7 +680,6 @@ function namechange(data, guid, socket, tried, callback) { } }, function (err, docs) { - //socket.emit('name', {type: "name", accepted: true}); if (old_name != name && !first && !no_name) { if ( data.hasOwnProperty("channel") && @@ -741,7 +735,6 @@ function namechange(data, guid, socket, tried, callback) { } function removename(guid, coll, socket) { - //coll = coll.replace(/ /g,''); checkIfChatEnabled(coll, socket, function (enabled) { if (!enabled) return; db.collection("user_names").find({ diff --git a/server/handlers/db.js b/server/handlers/db.js index 32538f39..8ba257f3 100644 --- a/server/handlers/db.js +++ b/server/handlers/db.js @@ -12,10 +12,6 @@ try { } var mongojs = require("mongojs"); var db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config); -var connected_db = mongojs( - "mongodb://" + mongo_config.host + "/user_credentials" -); -var ObjectId = mongojs.ObjectId; db.collection("chat_logs").createIndex({ createdAt: 1 diff --git a/server/handlers/frontpage.js b/server/handlers/frontpage.js index 9e81906a..c4b98865 100644 --- a/server/handlers/frontpage.js +++ b/server/handlers/frontpage.js @@ -128,7 +128,6 @@ function get_frontpage_lists(callback) { } function update_frontpage(coll, id, title, thumbnail, source, callback) { - //coll = coll.replace(/ /g,''); db.collection("frontpage_lists").find({ _id: coll }, function (e, doc) { diff --git a/server/handlers/functions.js b/server/handlers/functions.js index d858d8a4..4f4e9374 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -100,9 +100,7 @@ function remove_name_from_db(guid, channel) { channels: channel } }, - function (err, docs) { - //console.log("Pulled user from current channel"); - } + function (err, docs) {} ); } }); @@ -130,10 +128,6 @@ function isUrl(str) { function getSession(socket) { try { - /*var cookieParser = require("cookie-parser"); - var cookie = require("cookie"); - var parsedCookies = cookie.parse(socket.handshake.headers.cookie); - return parsedCookies["_uI"];*/ if (socket.cookie_id == undefined) throw "Undefined error"; return socket.cookie_id; } catch (e) { @@ -143,7 +137,6 @@ function getSession(socket) { socket.handshake.address + socket.handshake.headers["accept-language"] ); - //return "empty"; } } @@ -186,7 +179,6 @@ function check_inlist(coll, guid, socket, offline, callback, double_check) { if (typeof callback == "function") callback(); return; } - //coll = coll.replace(/ /g,''); if (!offline && coll != undefined) { db.collection("connected_users").update({ _id: coll @@ -256,10 +248,6 @@ function check_inlist(coll, guid, socket, offline, callback, double_check) { }); } } else if (docs.length == 0) { - //console.log("User doesn't have a name for some reason."); - //console.log("guid", guid); - //console.log("channel", coll); - //console.log("Trying to get a chat-name"); Chat.get_name(guid, { announce: false, socket: socket, @@ -323,7 +311,6 @@ function check_inlist(coll, guid, socket, offline, callback, double_check) { function (err, docs) {} ); } - // if (coll != undefined && coll != "") { db.collection("connected_users").update({ _id: "total_users" @@ -649,7 +636,6 @@ function left_channel(coll, guid, short_id, in_list, socket, change, caller) { } return; } - //coll = coll.replace(/ /g,''); db.collection("connected_users").update({ _id: coll }, { @@ -720,7 +706,6 @@ function left_channel(coll, guid, short_id, in_list, socket, change, caller) { } }, function (err, updated) { - //if(updated.nModified > 0) { db.collection("connected_users").update({ _id: "total_users" }, { @@ -735,7 +720,6 @@ function left_channel(coll, guid, short_id, in_list, socket, change, caller) { } else { remove_from_chat_channel(coll, guid); } - //} } ); } diff --git a/server/handlers/io.js b/server/handlers/io.js index 22e1fbcb..53bfddf4 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -1,4 +1,3 @@ -var cookieParser = require("cookie-parser"); var cookie = require("cookie"); var Functions = require(pathThumbnails + "/handlers/functions.js"); @@ -10,15 +9,6 @@ var ListSettings = require(pathThumbnails + "/handlers/list_settings.js"); var Frontpage = require(pathThumbnails + "/handlers/frontpage.js"); var Search = require(pathThumbnails + "/handlers/search.js"); var crypto = require("crypto"); -var Filter = require("bad-words"); -var filter = new Filter({ - placeHolder: "x" -}); -/*var filter = { - clean: function(str) { - return str; - } -}*/ var db = require(pathThumbnails + "/handlers/db.js"); module.exports = function () { @@ -26,7 +16,6 @@ module.exports = function () { try { var parsedCookies = cookie.parse(socket.handshake.headers.cookie); socket.cookie_id = parsedCookies["_uI"]; - //return socket.guid; } catch (e) { socket.cookie_id = "empty"; } @@ -47,7 +36,6 @@ module.exports = function () { socket.emit("ok"); }); - var ping_timeout; var socketid = socket.zoff_id; var coll; var in_list = false; @@ -70,7 +58,6 @@ module.exports = function () { if (msg.hasOwnProperty("channel")) { msg.channel = Functions.encodeChannelName(msg.channel); } - //channel = channel.replace(/ /g,''); if (offline) { db.collection("connected_users").update({ _id: "offline_users" @@ -178,9 +165,8 @@ module.exports = function () { connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1 ) { - coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + coll = msg.channel.toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); if (coll.indexOf("?") > -1) { coll = coll.substring(0, coll.indexOf("?")); } @@ -190,7 +176,6 @@ module.exports = function () { msg.channel, function (results) {} ); - //socket.cookie_id = msg.guid; guid = msg.guid; socketid = msg.socket_id; socket.zoff_id = socketid; @@ -216,16 +201,13 @@ module.exports = function () { socket.on("error_video", function (msg) { try { msg.channel = Functions.encodeChannelName(msg.channel); - var _list = msg.channel; //.replace(/ /g,''); + var _list = msg.channel; if (_list.length == 0) return; if (_list.indexOf("?") > -1) { _list = _list.substring(0, _list.indexOf("?")); msg.channel = _list; } coll = Functions.removeEmojis(_list).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -368,14 +350,13 @@ module.exports = function () { return; } var status = msg.status; - var channel = msg.channel; //.replace(/ /g,''); + var channel = msg.channel; if (status) { in_list = false; offline = true; if (channel != "") coll = channel; if (coll !== undefined) { coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); db.collection("connected_users").findAndModify({ query: { _id: coll @@ -591,7 +572,6 @@ module.exports = function () { msg.channel = Functions.encodeChannelName(msg.channel); } try { - //var _list = msg.channel.replace(/ /g,''); var _list = msg.channel; if (_list.length == 0) return; if (_list.indexOf("?") > -1) { @@ -599,9 +579,6 @@ module.exports = function () { msg.channel = _list; } coll = Functions.removeEmojis(_list).toLowerCase(); - //coll = coll.replace(/_/g, ""); - // - //coll = filter.clean(coll); } catch (e) { return; } @@ -621,12 +598,9 @@ module.exports = function () { if (obj.hasOwnProperty("channel")) { obj.channel = Functions.encodeChannelName(obj.channel); try { - coll = obj.channel.toLowerCase(); //.replace(/ /g,''); + coll = obj.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -660,12 +634,9 @@ module.exports = function () { !arr.hasOwnProperty("offsiteAdd")) ) { try { - coll = arr.list; //.replace(/ /g,''); + coll = arr.list; if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -684,12 +655,9 @@ module.exports = function () { if (msg.hasOwnProperty("channel")) { msg.channel = Functions.encodeChannelName(msg.channel); } - coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + coll = msg.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -707,12 +675,9 @@ module.exports = function () { } if (coll !== undefined) { try { - coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + coll = msg.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -728,7 +693,6 @@ module.exports = function () { if (inp.hasOwnProperty("channel")) { inp.channel = Functions.encodeChannelName(inp.channel); } - //if(coll != undefined) coll.replace(/ /g,''); ListSettings.password(inp, coll, guid, offline, socket); }); @@ -741,7 +705,6 @@ module.exports = function () { if (list.hasOwnProperty("channel")) { list.channel = Functions.encodeChannelName(list.channel); } - //if(coll != undefined) coll.replace(/ /g,''); List.skip(list, guid, coll, offline, socket); }); @@ -755,7 +718,6 @@ module.exports = function () { conf.channel = Functions.encodeChannelName(conf.channel); coll = conf.channel; } - //if(coll != undefined) coll.replace(/ /g,''); ListSettings.conf_function(conf, coll, guid, offline, socket); }); @@ -768,12 +730,9 @@ module.exports = function () { msg.channel = Functions.encodeChannelName(msg.channel); } try { - coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + coll = msg.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -805,12 +764,9 @@ module.exports = function () { obj.channel !== undefined ) { try { - coll = obj.channel.toLowerCase(); //.replace(/ /g,''); + coll = obj.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -864,9 +820,8 @@ module.exports = function () { msg.channel != "" && typeof msg.channel == "string" ) { - coll = msg.channel; //.replace(/ /g,''); + coll = msg.channel; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); Functions.left_channel( coll, guid, @@ -932,12 +887,9 @@ module.exports = function () { } if (coll !== undefined) { try { - coll = obj.channel.toLowerCase(); //.replace(/ /g,''); + coll = obj.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -994,18 +946,4 @@ module.exports = function () { }); }); }); - - //send_ping(); -}; - -/* -function send_ping() { -db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true}, function(err, docs){ -db.collection("connected_users").update({"_id": "total_users"}, {$add: {total_users: 0}}, {multi: true}, function(err, docs){ -db.collection("frontpage_lists").update({viewers: {$ne: 0}}, {$set: {"viewers": 0}}, {multi: true}, function(err, docs) { -io.emit("self_ping"); -setTimeout(send_ping, 25000); -}); -}); -}); -}*/ \ No newline at end of file +}; \ No newline at end of file diff --git a/server/handlers/list.js b/server/handlers/list.js index 2ba16944..902f5a9f 100644 --- a/server/handlers/list.js +++ b/server/handlers/list.js @@ -28,7 +28,6 @@ function now_playing(list, fn, socket) { function join_silent(msg, socket) { if (typeof msg === "object" && msg !== undefined && msg !== null) { var channelName = msg.channel; - var tryingPassword = false; var password = ""; if (msg.password != "") { tryingPassword = true; @@ -39,7 +38,7 @@ function join_silent(msg, socket) { .digest("base64"); } - channelName = channelName.toLowerCase(); //.replace(/ /g,''); + channelName = channelName.toLowerCase(); channelName = Functions.removeEmojis(channelName).toLowerCase(); db.collection(channelName + "_settings").find(function (err, docs) { if (docs.length == 0) { @@ -61,7 +60,6 @@ function join_silent(msg, socket) { } function list(msg, guid, coll, offline, socket) { - var socketid = socket.zoff_id; if (typeof msg === "object" && msg !== undefined && msg !== null) { Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, @@ -244,19 +242,14 @@ function list(msg, guid, coll, offline, socket) { } function skip(list, guid, coll, offline, socket, callback) { - var socketid = socket.zoff_id; - if (list !== undefined && list !== null && list !== "") { if (coll == undefined && list.hasOwnProperty("channel")) coll = list.channel.toLowerCase(); if (coll !== undefined) { try { - coll = list.channel.toLowerCase(); //.replace(/ /g,''); + coll = list.channel.toLowerCase(); if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } @@ -356,7 +349,6 @@ function skip(list, guid, coll, offline, socket, callback) { error = true; } hash = adminpass; - //db.collection(coll + "_settings").find(function(err, docs){ var strictSkip = false; var strictSkipNumber = 10; if (docs[0].strictSkip) strictSkip = docs[0].strictSkip; @@ -488,7 +480,6 @@ function skip(list, guid, coll, offline, socket, callback) { } } ); - //}); } else { socket.emit("auth_required"); } @@ -506,9 +497,6 @@ function skip(list, guid, coll, offline, socket, callback) { } function change_song(coll, error, id, conf, callback, socket) { - //coll = coll.replace(/ /g,''); - //db.collection(coll + "_settings").find(function(err, docs){ - var startTime = conf[0].startTime; if (conf !== null && conf.length !== 0) { db.collection(coll).aggregate( [{ @@ -678,11 +666,9 @@ function change_song(coll, error, id, conf, callback, socket) { } ); } - //}); } function change_song_post(coll, next_song, conf, callback, socket, removed) { - //coll = coll.replace(/ /g,''); db.collection(coll).aggregate( [{ $match: { @@ -743,7 +729,6 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) { } }, function (err, returnDocs) { - //db.collection(coll + "_settings").find({id: "config"}, function(err, conf){ if (!callback) { io.to(coll).emit("channel", { type: "song_change", @@ -778,7 +763,6 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) { docs[0].thumbnail, docs[0].source ); - //}); } ); } @@ -789,7 +773,6 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) { } function send_list(coll, socket, send, list_send, configs, shuffled) { - //coll = coll.replace(/ /g,''); db.collection(coll + "_settings").aggregate( [{ $match: { @@ -855,7 +838,7 @@ function send_list(coll, socket, send, list_send, configs, shuffled) { ], function ( err, - docs //db.collection(coll).find({type: {$ne: "suggested"}}, function(err, docs) + docs ) { if (docs.length > 0) { db.collection(coll).find({ @@ -1096,7 +1079,6 @@ function send_list(coll, socket, send, list_send, configs, shuffled) { } function end(obj, coll, guid, offline, socket) { - var socketid = socket.zoff_id; if (typeof obj !== "object") { return; } @@ -1203,7 +1185,6 @@ function end(obj, coll, guid, offline, socket) { } function send_play(coll, socket, broadcast) { - //coll = coll.replace(/ /g,''); db.collection(coll).find({ now_playing: true }, function (err, np) { @@ -1226,7 +1207,6 @@ function send_play(coll, socket, broadcast) { }; if (socket === undefined) { io.to(coll).emit("np", toSend); - // getNextSong(coll, undefined); var url = "https://img.youtube.com/vi/" + np[0].id + "/mqdefault.jpg"; @@ -1260,12 +1240,8 @@ function send_play(coll, socket, broadcast) { } function sendColor(coll, socket, url, ajax, res) { - if (coll != undefined && typeof coll == "string") { - //coll = coll.replace(/ /g,''); - } if (url.indexOf("://") == -1) url = "https://img.youtube.com/vi/" + url + "/mqdefault.jpg"; - //var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'; Jimp.read(url) .then(function (image) { diff --git a/server/handlers/list_change.js b/server/handlers/list_change.js index 35355a8b..7d0c24d1 100644 --- a/server/handlers/list_change.js +++ b/server/handlers/list_change.js @@ -7,7 +7,6 @@ var crypto = require("crypto"); var db = require(pathThumbnails + "/handlers/db.js"); function addFromOtherList(arr, guid, offline, socket) { - var socketid = socket.zoff_id; if (typeof arr == "object") { if ( !arr.hasOwnProperty("channel") || @@ -29,8 +28,8 @@ function addFromOtherList(arr, guid, offline, socket) { socket.emit("update_required", result); return; } - var channel = arr.channel; //.replace(/ /g,'').toLowerCase(); - var new_channel = Functions.encodeChannelName(arr.new_channel); //.replace(/ /g, '').toLowerCase(); + var channel = arr.channel; + var new_channel = Functions.encodeChannelName(arr.new_channel); db.collection("frontpage_lists").find({ _id: new_channel }, function ( @@ -359,7 +358,6 @@ function addFromOtherList(arr, guid, offline, socket) { } function addPlaylist(arr, guid, offline, socket) { - var socketid = socket.zoff_id; if (typeof arr == "object") { if ( !arr.hasOwnProperty("channel") || @@ -380,7 +378,7 @@ function addPlaylist(arr, guid, offline, socket) { socket.emit("update_required", result); return; } - var channel = arr.channel; //.replace(/ /g,'').toLowerCase(); + var channel = arr.channel; if (arr.length == 0 || arr.songs.length == 0) { socket.emit("toast", "Empty list.."); return; @@ -683,7 +681,6 @@ function addPlaylist(arr, guid, offline, socket) { } function add_function(arr, coll, guid, offline, socket) { - var socketid = socket.zoff_id; if ( typeof arr === "object" && arr !== undefined && @@ -1085,9 +1082,8 @@ function voteUndecided(msg, coll, guid, offline, socket) { socket.emit("update_required", result); return; } - coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + coll = msg.channel.toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, adminpass @@ -1163,7 +1159,6 @@ function voteUndecided(msg, coll, guid, offline, socket) { } function shuffle(msg, coll, guid, offline, socket) { - var socketid = socket.zoff_id; if (!msg.hasOwnProperty("channel") || typeof msg.channel != "string") { var result = { channel: { @@ -1182,9 +1177,8 @@ function shuffle(msg, coll, guid, offline, socket) { socket.emit("update_required", result); return; } - coll = msg.channel.toLowerCase(); //.replace(/ /g,''); + coll = msg.channel.toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, adminpass @@ -1263,13 +1257,6 @@ function shuffle(msg, coll, guid, offline, socket) { socket.emit("auth_required"); } }); - - var complete = function (tot, curr) { - if (tot == curr) { - List.send_list(coll, undefined, false, true, false); - List.getNextSong(coll, undefined); - } - }; } ); }); @@ -1278,9 +1265,6 @@ function shuffle(msg, coll, guid, offline, socket) { function del(params, socket, socketid) { if (params.id) { var coll = Functions.removeEmojis(params.channel).toLowerCase(); - //coll = coll.replace(/_/g, "").replace(/ /g,''); - - //coll = filter.clean(coll); db.collection(coll + "_settings").find(function (err, docs) { if ( docs !== null && @@ -1330,7 +1314,6 @@ function del(params, socket, socketid) { } function delete_all(msg, coll, guid, offline, socket) { - var socketid = socket.zoff_id; if (typeof msg == "object") { if (!msg.hasOwnProperty("channel") || typeof msg.channel != "string") { var result = { @@ -1354,9 +1337,7 @@ function delete_all(msg, coll, guid, offline, socket) { if (coll == undefined) { coll = msg.channel; } - //coll = coll.replace(/ /g,''); coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = filter.clean(coll); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, adminpass, @@ -1435,7 +1416,6 @@ function delete_all(msg, coll, guid, offline, socket) { } function vote(coll, id, guid, socket) { - //coll = coll.replace(/ /g,''); db.collection(coll).find({ id: id, now_playing: false, diff --git a/server/handlers/list_settings.js b/server/handlers/list_settings.js index e139c6d3..b9017a17 100644 --- a/server/handlers/list_settings.js +++ b/server/handlers/list_settings.js @@ -31,13 +31,9 @@ function password(inp, coll, guid, offline, socket) { coll = inp.channel; if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } - //coll = coll.replace(/ /g,''); uncrypted = pw; pw = Functions.hash_pass(Functions.decrypt_string(pw), true); Functions.check_inlist(coll, guid, socket, offline, undefined, "place 8"); @@ -129,12 +125,9 @@ function conf_function(params, coll, guid, offline, socket) { if (params !== undefined && params !== null && params !== "") { if (coll !== undefined) { try { - coll = params.channel; //.replace(/ /g,''); + coll = params.channel; if (coll.length == 0) return; coll = Functions.removeEmojis(coll).toLowerCase(); - //coll = coll.replace(/_/g, ""); - - //coll = filter.clean(coll); } catch (e) { return; } diff --git a/server/handlers/notifications.js b/server/handlers/notifications.js index e262c77f..24b552f4 100644 --- a/server/handlers/notifications.js +++ b/server/handlers/notifications.js @@ -2,11 +2,9 @@ var path = require("path"); function requested_change(type, string, channel) { try { - //channel = channel.replace(/ /g,''); var nodemailer = require("nodemailer"); var mailconfig = require(path.join(__dirname, "../config/mailconfig.js")); - - let transporter = nodemailer.createTransport(mailconfig); + var transporter = nodemailer.createTransport(mailconfig); transporter.verify(function (error, success) { if (error) { diff --git a/server/handlers/suggestions.js b/server/handlers/suggestions.js index 1d4e3eec..f9a96407 100644 --- a/server/handlers/suggestions.js +++ b/server/handlers/suggestions.js @@ -23,20 +23,18 @@ function thumbnail(msg, coll, guid, offline, socket) { thumbnail: { expected: "string", got: msg.hasOwnProperty("thumbnail") ? - typeof msg.thumbnail : - undefined + typeof msg.thumbnail : undefined }, adminpass: { expected: "string", got: msg.hasOwnProperty("adminpass") ? - typeof msg.adminpass : - undefined + typeof msg.adminpass : undefined } }; socket.emit("update_required", result); return; } - //coll = coll.replace(/ /g,''); + Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, adminpass @@ -125,20 +123,17 @@ function description(msg, coll, guid, offline, socket) { description: { expected: "string", got: msg.hasOwnProperty("description") ? - typeof msg.description : - undefined + typeof msg.description : undefined }, adminpass: { expected: "string", got: msg.hasOwnProperty("adminpass") ? - typeof msg.adminpass : - undefined + typeof msg.adminpass : undefined } }; socket.emit("update_required", result); return; } - //coll = coll.replace(/ /g,''); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, adminpass, @@ -227,14 +222,12 @@ function rules(msg, coll, guid, offline, socket) { adminpass: { expected: "string", got: msg.hasOwnProperty("adminpass") ? - typeof msg.adminpass : - undefined + typeof msg.adminpass : undefined } }; socket.emit("update_required", result); return; } - //coll = coll.replace(/ /g,''); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function ( userpass, adminpass,