Deactivated usernames for now, until it is more stabil

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-13 19:35:56 +02:00
parent 22b62e36cd
commit bc71e67ca4
6 changed files with 27 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ var chat = function(msg, guid, offline, socket) {
} }
var coll = msg.channel; var coll = msg.channel;
db.collection(coll).find({views:{$exists:true}}, function(err, docs){ db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == decrypt_string(socketid, msg.pass)))) { if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
var data = msg.data; var data = msg.data;
Functions.check_inlist(coll, guid, socket, offline); Functions.check_inlist(coll, guid, socket, offline);
if(data !== "" && data !== undefined && data !== null && if(data !== "" && data !== undefined && data !== null &&
@@ -107,7 +107,7 @@ var generate_name = function(guid, announce_payload) {
} }
}); });
} else { } else {
generate_name(tmp_name + "_", announce_payload); generate_name(tmp_name, announce_payload);
} }
}) })
} }

View File

@@ -17,6 +17,7 @@ module.exports = function() {
var socketid = socket.zoff_id; var socketid = socket.zoff_id;
var coll; var coll;
var in_list = false; var in_list = false;
var name = "";
var short_id; var short_id;
Chat.get_name(guid, {announce: false}); Chat.get_name(guid, {announce: false});
Functions.get_short_id(socketid, 4, socket); Functions.get_short_id(socketid, 4, socket);
@@ -34,6 +35,13 @@ module.exports = function() {
db.collection("frontpage_lists").update({"_id": channel}, {$inc: {viewers: 1}}, {upsert: true}, function(){}); db.collection("frontpage_lists").update({"_id": channel}, {$inc: {viewers: 1}}, {upsert: true}, function(){});
}); });
} }
/*if(name != "") {
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: name}}, {upsert: true}, function(err, updated) {
if(updated.nModified == 1) {
db.collection("user_names").update({"guid": guid}, {$set: {name: name}}, {upsert:true}, function(err, update){});
}
});
}*/
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, {upsert: true}, function(err, docs){}); db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, {upsert: true}, function(err, docs){});
}); });
@@ -122,18 +130,21 @@ module.exports = function() {
} }
}); });
socket.on('namechange', function(msg) /*socket.on('namechange', function(msg)
{ {
if(coll == undefined) { if(coll == undefined) {
coll = msg.channel; coll = msg.channel;
} }
Chat.namechange(msg.name, guid, coll); Chat.namechange(msg.name, guid, coll, function(new_name) {
name = new_name;
});
}); });
socket.on('removename', function() socket.on('removename', function()
{ {
Chat.removename(guid, coll); Chat.removename(guid, coll);
}); name = "";
});*/
socket.on('chat', function (msg) { socket.on('chat', function (msg) {
Chat.chat(msg, guid, offline, socket); Chat.chat(msg, guid, offline, socket);
@@ -377,13 +388,16 @@ module.exports = function() {
var send_ping = function(guid, coll, socket) { var send_ping = function(guid, coll, socket) {
console.log(guid, coll); console.log(guid, coll);
if(coll == undefined) { if(coll == undefined) {
ping_timeout = setTimeout(send_ping, 3000); ping_timeout = setTimeout(function(){
send_ping(guid, coll, socket);
}, 3000);
} else { } else {
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, docs) { db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, docs) {
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, docs) { db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, docs) {
db.collection("frontpage_lists").update({"_id": coll, viewers: {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) { db.collection("frontpage_lists").update({"_id": coll, viewers: {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) {
db.collection("user_names").find({"guid": guid}, function(err, user_name) { db.collection("user_names").find({"guid": guid}, function(err, user_name) {
if(user_name.length > 0) { if(user_name.length > 0) {
name = user_name[0].name;
db.collection("user_names").remove({"guid": guid}, function(err, docs) { db.collection("user_names").remove({"guid": guid}, function(err, docs) {
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: user_name[0].name}}, function(err, docs) { db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: user_name[0].name}}, function(err, docs) {
socket.emit("self_ping"); socket.emit("self_ping");
@@ -400,6 +414,7 @@ module.exports = function() {
} }
}*/ }*/
}); });
send_ping(); send_ping();
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@ var Chat = {
channel_received: 0, channel_received: 0,
all_received: 0, all_received: 0,
chat_help: ["/name <new name> to change name", "/removename to remove name"], chat_help: [/*"/name <new name> to change name", "/removename to remove name"*/ "There are no commands.. As of now!"],
namechange: function(newName) namechange: function(newName)
{ {
@@ -20,9 +20,9 @@ var Chat = {
{ {
if(data.value.length > 150) if(data.value.length > 150)
return; return;
if(data.value.startsWith("/name ")){ /*if(data.value.startsWith("/name ")){
Chat.namechange(data.value.substring(6)); Chat.namechange(data.value.substring(6));
} else if(data.value.startsWith("/help")){ } else */ if(data.value.startsWith("/help")){
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){ if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
if($("#chatall").children().length > 100){ if($("#chatall").children().length > 100){
$("#chatall").children()[0].remove() $("#chatall").children()[0].remove()

View File

@@ -128,8 +128,6 @@ db.on('error',function(err) {
}); });
/* Resetting usernames, and connected users */ /* Resetting usernames, and connected users */
db.collection("user_names").remove({"guid": {$exists: true}}, {multi: true, upsert: true}, function(err, docs){});
db.collection("user_names").update({"_id": "all_names"}, {$set: {names: []}}, {multi: true, upsert: true}, function(err, docs){});
db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true, upsert: true}, function(err, docs){}); db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true, upsert: true}, function(err, docs){});
db.collection("connected_users").update({"_id": "total_users"}, {$set: {total_users: 0}}, {multi: true, upsert: true}, function(err, docs) {}); db.collection("connected_users").update({"_id": "total_users"}, {$set: {total_users: 0}}, {multi: true, upsert: true}, function(err, docs) {});
db.collection("frontpage_lists").update({viewers: {$ne: 0}}, {$set: {"viewers": 0}}, {multi: true, upsert: true}, function(err, docs) {}); db.collection("frontpage_lists").update({viewers: {$ne: 0}}, {$set: {"viewers": 0}}, {multi: true, upsert: true}, function(err, docs) {});