mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Trying a fix for chat names crashing the server
This commit is contained in:
		| @@ -85,7 +85,7 @@ function all_chat(msg, guid, offline, socket) { | ||||
|     } | ||||
| } | ||||
|  | ||||
| function namechange(data, guid, socket) { | ||||
| function namechange(data, guid, socket, tried) { | ||||
|     if(!data.hasOwnProperty("name") || data.name.length > 10 || !data.hasOwnProperty("channel")) return; | ||||
|     var pw = ""; | ||||
|     var new_password; | ||||
| @@ -122,6 +122,7 @@ function namechange(data, guid, socket) { | ||||
|         } | ||||
|         if(accepted_password) { | ||||
|             db.collection("user_names").find({"guid": guid}, function(err, names) { | ||||
|                 if(names.length > 0) { | ||||
|                     var old_name = names[0].name; | ||||
|                     db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function() {}); | ||||
|                     db.collection("user_names").update({"guid": guid}, {$set: {name: name, icon: icon}}, function(err, docs) { | ||||
| @@ -133,6 +134,14 @@ function namechange(data, guid, socket) { | ||||
|                             } | ||||
|                         }); | ||||
|                     }); | ||||
|                 } else { | ||||
|                     if(tried < 3 || tried == undefined) { | ||||
|                         if(tried == undefined) { | ||||
|                             tried = 1; | ||||
|                         } | ||||
|                         namechange(data, guid, socket, tried + 1); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|         } else { | ||||
|             socket.emit('name', {type: "name", accepted: false}); | ||||
|   | ||||
| @@ -2,13 +2,12 @@ VERSION = 3; | ||||
|  | ||||
| var server; | ||||
| var add = ""; | ||||
| const path = require('path'); | ||||
| const publicPath = path.join(__dirname, 'public'); | ||||
| var path = require('path'); | ||||
| var publicPath = path.join(__dirname, 'public'); | ||||
| pathThumbnails = __dirname; | ||||
| var express = require('express'); | ||||
| var app = express(); | ||||
| var exphbs = require('express-handlebars'); | ||||
| console.log(path.join(__dirname, 'config')); | ||||
| var cert_config = require(path.join(path.join(__dirname, 'config'), 'cert_config.js')); | ||||
| var hbs = exphbs.create({ | ||||
| 	defaultLayout: publicPath + '/layouts/main', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user