From ebbdcbe295fab7b86d50526d3b32163af255217f Mon Sep 17 00:00:00 2001 From: rainbownapkin Date: Sun, 1 Dec 2024 17:50:57 -0500 Subject: [PATCH] Connected users now get kicked on channel ban. --- src/schemas/channel/channelSchema.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/schemas/channel/channelSchema.js b/src/schemas/channel/channelSchema.js index 7b2f281..1f13db9 100644 --- a/src/schemas/channel/channelSchema.js +++ b/src/schemas/channel/channelSchema.js @@ -19,6 +19,7 @@ const {mongoose} = require('mongoose'); const {validationResult, matchedData} = require('express-validator'); //Local Imports +const server = require('../../server'); const statModel = require('../statSchema'); const {userModel} = require('../userSchema'); const permissionModel = require('../permissionSchema'); @@ -414,6 +415,18 @@ channelSchema.methods.banByUserDoc = async function(userDB, expirationDays, banA banAlts } + const activeChan = server.channelManager.activeChannels.get(this.name); + if(activeChan != null){ + const userConn = activeChan.userList.get(userDB.user); + if(userConn != null){ + if(expirationDays < 0){ + userConn.disconnect("You have been permanently banned from this channel!"); + }else{ + userConn.disconnect(`You have been banned from this channel for ${expirationDays} day(s)!`); + } + } + } + //Push the ban to the list this.banList.push(banDoc);