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();