From 486f2be7db4a06ded6904f7563d2b4c2ada4ed64 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 9 Jul 2022 05:12:13 -0400 Subject: [PATCH] parity --- src/Channel.js | 14 ++++++++++++++ src/Message.js | 24 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Channel.js b/src/Channel.js index 1ed5746..92c3284 100644 --- a/src/Channel.js +++ b/src/Channel.js @@ -647,6 +647,20 @@ class Channel extends EventEmitter { }) } + unban(_id) { + this.connections.filter((usr) => usr.participantId == user.participantId).forEach(u => { + if (user.bantime) { + delete user.bantime; + } + + if (user.bannedtime) { + delete user.bannedtime; + } + + this.bans.delete(user.user._id); + }); + } + Notification(who, title, text, html, duration, target, klass, id) { new Notification({ id: id, diff --git a/src/Message.js b/src/Message.js index a41ceb1..c527eaf 100644 --- a/src/Message.js +++ b/src/Message.js @@ -212,10 +212,12 @@ module.exports = (cl) => { }); cl.on('kickban', msg => { - if (cl.channel.crown == null) return; - if (!(cl.channel && cl.participantId)) return; - if (!cl.channel.crown.userId) return; - if (!(cl.user._id == cl.channel.crown.userId)) return; + if (!admin) { + if (cl.channel.crown == null) return; + if (!(cl.channel && cl.participantId)) return; + if (!cl.channel.crown.userId) return; + if (!(cl.user._id == cl.channel.crown.userId)) return; + } if (msg.hasOwnProperty('_id') && typeof msg._id == "string") { if (!cl.quotas.kickban.attempt() && !admin) return; let _id = msg._id; @@ -224,6 +226,20 @@ module.exports = (cl) => { } }); + cl.on('unban', (msg, admin) => { + if (!admin) { + if (cl.channel.crown == null) return; + if (!(cl.channel && cl.participantId)) return; + if (!cl.channel.crown.userId) return; + if (!(cl.user._id == cl.channel.crown.userId)) return; + } + if (msg.hasOwnProperty('_id') && typeof msg._id == "string") { + if (!cl.quotas.kickban.attempt() && !admin) return; + let _id = msg._id; + cl.channel.unban(_id); + } + }); + cl.on("bye", msg => { cl.user.stopFlagEvents(); cl.destroy();