Finished up implementing channel-based user bans.

This commit is contained in:
rainbow napkin 2024-12-01 17:18:43 -05:00
parent ef79e9941c
commit 96953979a2
19 changed files with 518 additions and 202 deletions

View file

@ -46,6 +46,19 @@ module.exports = class{
//Get the active channel based on the socket
var {activeChan, chanDB} = await this.getActiveChan(socket);
//Check for ban
const ban = await chanDB.checkBanByUserDoc(userDB);
if(ban != null){
//Toss out banned user's
if(ban.expirationDays < 0){
socket.emit("kick", {type: "Unauthorized", reason: "You have been permanently banned from this channel!"});
}else{
socket.emit("kick", {type: "Unauthorized", reason: `You have been temporarily banned from this channel, and will be unbanned in ${ban.getDaysUntilExpiration()} day(s)!`});
}
socket.disconnect();
return;
}
//Define listeners
this.defineListeners(socket);
this.chatHandler.defineListeners(socket);