Updates for better handling of deleting list and inserting full playlist

This commit is contained in:
Kasper Rynning-Tønnesen
2018-04-05 13:52:05 +02:00
parent 72f204825e
commit 7fde03e88e
2 changed files with 12 additions and 10 deletions

View File

@@ -301,17 +301,15 @@ module.exports = function() {
}); });
socket.on('delete_all', function(msg) { socket.on('delete_all', function(msg) {
if(coll !== undefined) { try {
try { coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = msg.channel.toLowerCase().replace(/ /g,''); if(coll.length == 0) return;
if(coll.length == 0) return; coll = emojiStrip(coll).toLowerCase();
coll = emojiStrip(coll).toLowerCase(); coll = coll.replace(/_/g, "");
coll = coll.replace(/_/g, "");
coll = filter.clean(coll); coll = filter.clean(coll);
} catch(e) { } catch(e) {
return; return;
}
} }
ListChange.delete_all(msg, coll, guid, offline, socket); ListChange.delete_all(msg, coll, guid, offline, socket);

View File

@@ -164,6 +164,10 @@ function addPlaylist(arr, guid, offline, socket) {
var now_playing = false; var now_playing = false;
if(np.length == 0) now_playing = true; if(np.length == 0) now_playing = true;
db.collection(channel + "_settings").find({id: "config"}, function(e, conf) { db.collection(channel + "_settings").find({id: "config"}, function(e, conf) {
if(arr.length == 0) {
socket.emit("toast", "Empty list..");
return;
}
if(conf.length > 0) { if(conf.length > 0) {
var hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(socketid, arr.adminpass), true)); var hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(socketid, arr.adminpass), true));
if((conf[0].userpass == "" || !conf[0].userpass || conf[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, arr.userpass)).digest("base64"))) { if((conf[0].userpass == "" || !conf[0].userpass || conf[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, arr.userpass)).digest("base64"))) {