Fixed issue with channels having spaces

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-18 18:19:42 +01:00
parent 2e29f8e20f
commit f70cf00fd1
11 changed files with 55 additions and 37 deletions

View File

@@ -46,7 +46,7 @@ function list(msg, guid, coll, offline, socket) {
socket.emit('update_required', result);
return;
}
coll = msg.channel.toLowerCase();
coll = msg.channel.toLowerCase().replace(/ /g,'');
var pass = crypto.createHash('sha256').update(Functions.decrypt_string(socketid, msg.pass)).digest("base64");
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
if(frontpage_lists.length == 1)
@@ -108,7 +108,7 @@ function skip(list, guid, coll, offline, socket) {
if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel.toLowerCase();
if(coll !== undefined) {
try {
coll = list.channel.toLowerCase();
coll = list.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
@@ -225,6 +225,7 @@ function skip(list, guid, coll, offline, socket) {
}
function change_song(coll, error, id, callback, socket) {
coll = coll.replace(/ /g,'');
db.collection(coll + "_settings").find(function(err, docs){
var startTime = docs[0].startTime;
if(docs !== null && docs.length !== 0)
@@ -321,8 +322,8 @@ function change_song(coll, error, id, callback, socket) {
});
}
function change_song_post(coll, next_song, callback, socket)
{
function change_song_post(coll, next_song, callback, socket) {
coll = coll.replace(/ /g,'');
db.collection(coll).aggregate([{
$match:{
now_playing:false,
@@ -381,6 +382,7 @@ function change_song_post(coll, next_song, callback, socket)
function send_list(coll, socket, send, list_send, configs, shuffled)
{
coll = coll.replace(/ /g,'');
db.collection(coll + "_settings").find({id: "config"}, function(err, _conf){
var conf = _conf;
if(conf.length == 0) {
@@ -535,6 +537,7 @@ function end(obj, coll, guid, offline, socket) {
socket.emit("update_required", result);
return;
}
coll = coll.replace(/ /g,'');
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
obj.pass = userpass;
@@ -578,8 +581,8 @@ function end(obj, coll, guid, offline, socket) {
}
}
function send_play(coll, socket, broadcast)
{
function send_play(coll, socket, broadcast) {
coll = coll.replace(/ /g,'');
db.collection(coll).find({now_playing:true}, function(err, np){
db.collection(coll + "_settings").find(function(err, conf){
if(err !== null) console.log(err);
@@ -624,6 +627,7 @@ function send_play(coll, socket, broadcast)
}
function sendColor(coll, socket, id) {
coll = coll.replace(/ /g,'');
var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
Jimp.read(url).then(function (image) {
@@ -637,6 +641,7 @@ function sendColor(coll, socket, id) {
}
function getNextSong(coll, callback) {
coll = coll.replace(/ /g,'');
db.collection(coll).aggregate([{
$match:{
views:{
@@ -663,9 +668,9 @@ function getNextSong(coll, callback) {
});
}
function left_channel(coll, guid, short_id, in_list, socket, change)
{
function left_channel(coll, guid, short_id, in_list, socket, change) {
if(!coll) return;
coll = coll.replace(/ /g,'');
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, updated) {
if(updated.nModified > 0) {
db.collection("connected_users").find({"_id": coll}, function(err, new_doc){