From 2076851604f0da75df81f1d7b0d0f28adf8c7185 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 9 Jul 2022 00:44:49 -0400 Subject: [PATCH] fix "name" admin message --- src/Message.js | 15 ++++++--------- src/Server.js | 3 ++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Message.js b/src/Message.js index ea30c6a..645abdd 100644 --- a/src/Message.js +++ b/src/Message.js @@ -383,21 +383,18 @@ module.exports = (cl) => { cl.on('name', (msg, admin) => { if (!admin) return; - + if (!msg.hasOwnProperty('_id')) return; if (!msg.hasOwnProperty('name')) return; - - let c; - - for (const conn of cl.server.connections) { + + for (const [mapID, conn] of cl.server.connections) { + if (!conn.user) return; if (conn.user._id == msg._id) { - c = conn; - break; + let c = conn; + c.userset(msg.name, true); } } - if (!c) return; - c.userset(msg.name, true); }); } diff --git a/src/Server.js b/src/Server.js index 8d44c46..dec3bb7 100644 --- a/src/Server.js +++ b/src/Server.js @@ -88,7 +88,8 @@ class Server extends EventEmitter { "unsubscribe from admin stream", "data", "channel message", - "channel_flag" + "channel_flag", + "name" ]; this.welcome_motd = config.motd || "You agree to read this message.";