From afdb3c71b98c928b49912666543e2dba3d2a7224 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sun, 11 Sep 2022 01:51:53 -0400 Subject: [PATCH] fix stuff --- src/Channel.js | 6 ++---- src/Client.js | 18 +++++++++++++----- src/Message.js | 6 ++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Channel.js b/src/Channel.js index 4a1381c..af5a541 100644 --- a/src/Channel.js +++ b/src/Channel.js @@ -135,10 +135,8 @@ class Channel extends EventEmitter { let col = getTimeColor(); let col2 = new Color(col.r - 0x40, col.g - 0x40, col.b - 0x40); - this.settings.changeSettings({ - color: col.toHexa(), - color2: col2.toHexa() - }); + this.settings.color = col.toHexa(); + this.settings.color2 = col.toHexa(); for (let key in this.settings) { this.server.lobbySettings[key] = this.settings[key]; diff --git a/src/Client.js b/src/Client.js index 2d4fe47..bc89c71 100644 --- a/src/Client.js +++ b/src/Client.js @@ -122,9 +122,9 @@ class Client extends EventEmitter { userset(name, admin) { if (name.length > 40 && !admin) return; if (!this.quotas.userset.attempt()) return; + if (!this.user.hasFlag('freeze_name', true)) { this.user.name = name; - Database.getUserData(this, this.server).then((usr) => { - if (!this.user.hasFlag('freeze_name', true)) { + Database.getUserData(this, this.server).then((usr) => { Database.updateUser(this.user._id, this.user); this.server.rooms.forEach((room) => { @@ -132,8 +132,8 @@ class Client extends EventEmitter { name: name }); }); - } - }); + }); + } } /** @@ -218,7 +218,15 @@ class Client extends EventEmitter { let channels = []; this.server.rooms.forEach(ch => { - channels.push(ch.fetchChannelData()); + let ppl = []; + for (let p of ch.fetchChannelData().ppl) { + ppl.push({ + user: p + }); + } + channels.push({ + participants: ppl + }); }); let users = []; diff --git a/src/Message.js b/src/Message.js index d79d248..bf34b9b 100644 --- a/src/Message.js +++ b/src/Message.js @@ -247,7 +247,8 @@ module.exports = (cl) => { }); cl.on("admin message", msg => { - if (!(cl.channel && cl.participantId)) return; + console.log(msg); + // if (!(cl.channel && cl.participantId)) return; if (!msg.hasOwnProperty('password') || !msg.hasOwnProperty('msg')) return; if (typeof msg.msg != 'object') return; if (msg.password !== cl.server.adminpass) return; @@ -258,7 +259,8 @@ module.exports = (cl) => { // TODO move all admin messages to their own stream cl.on('color', (msg, admin) => { if (!admin) return; - if (typeof cl.channel.verifyColor(msg.color) != 'string') return; + if (!msg.color) return; + // if (typeof cl.channel.verifyColor(msg.color) != 'string') return; if (!msg.hasOwnProperty('id') && !msg.hasOwnProperty('_id')) return; cl.server.connections.forEach(c => { if (c.destroied) return;