This commit is contained in:
Hri7566 2022-07-09 05:12:13 -04:00
parent 008092ac86
commit 486f2be7db
2 changed files with 34 additions and 4 deletions

View File

@ -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) { Notification(who, title, text, html, duration, target, klass, id) {
new Notification({ new Notification({
id: id, id: id,

View File

@ -212,10 +212,12 @@ module.exports = (cl) => {
}); });
cl.on('kickban', msg => { cl.on('kickban', msg => {
if (cl.channel.crown == null) return; if (!admin) {
if (!(cl.channel && cl.participantId)) return; if (cl.channel.crown == null) return;
if (!cl.channel.crown.userId) return; if (!(cl.channel && cl.participantId)) return;
if (!(cl.user._id == cl.channel.crown.userId)) 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 (msg.hasOwnProperty('_id') && typeof msg._id == "string") {
if (!cl.quotas.kickban.attempt() && !admin) return; if (!cl.quotas.kickban.attempt() && !admin) return;
let _id = msg._id; 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.on("bye", msg => {
cl.user.stopFlagEvents(); cl.user.stopFlagEvents();
cl.destroy(); cl.destroy();