Added silent-join

This commit is contained in:
Kasper Rynning-Tønnesen
2019-09-17 23:00:25 +02:00
parent 50694e32db
commit f5d9272a42
3 changed files with 49 additions and 2 deletions

View File

@@ -504,6 +504,19 @@ module.exports = function() {
});
});
socket.on("join_silent", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list;
}
if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel);
} else {
return;
}
List.join_silent(msg, socket);
});
socket.on("list", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?"));

View File

@@ -31,6 +31,41 @@ 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;
password = Functions.decrypt_string(msg.password);
password = crypto
.createHash("sha256")
.update(password)
.digest("base64");
}
channelName = channelName.toLowerCase(); //.replace(/ /g,'');
channelName = Functions.removeEmojis(channelName).toLowerCase();
db.collection(channelName + "_settings").find(function(err, docs) {
if(docs.length == 0) {
socket.emit("join_silent_declined", "");
return;
}
if(docs[0].userpass == "" || docs[0].userpass == undefined || docs[0].userpass == password) {
socket.join(channelName);
socket.emit("join_silent_accepted", "");
send_play(channelName, socket);
} else {
socket.emit("join_silent_declined", "");
}
});
} else {
return;
}
}
function list(msg, guid, coll, offline, socket) {
var socketid = socket.zoff_id;
if (typeof msg === "object" && msg !== undefined && msg !== null) {
@@ -1245,6 +1280,7 @@ function getNextSong(coll, socket, callback) {
);
}
module.exports.join_silent = join_silent;
module.exports.sendColor = sendColor;
module.exports.now_playing = now_playing;
module.exports.list = list;

View File

@@ -244,9 +244,7 @@ function conf_function(params, coll, guid, offline, socket) {
var adminpass = params.adminpass;
var skipping = params.skipping;
var shuffling = params.shuffling;
var userpass = Functions.decrypt_string(params.userpass);
if (
(!params.userpass_changed && frontpage) ||
(params.userpass_changed && userpass == "")