Fixed expiration handlers
This commit is contained in:
parent
853f67fe15
commit
730d816c45
5 changed files with 44 additions and 19 deletions
|
|
@ -318,16 +318,23 @@ channelSchema.statics.reqPermCheck = function(perm, chanField = "chanName"){
|
|||
channelSchema.statics.processExpiredBans = async function(){
|
||||
const chanDB = await this.find({});
|
||||
|
||||
chanDB.forEach((channel) => {
|
||||
channel.banList.forEach(async (ban, i) => {
|
||||
for(let chanIndex in chanDB){
|
||||
//Pull channel from channels by index
|
||||
const channel = chanDB[chanIndex];
|
||||
|
||||
//channel.banList.forEach(async (ban, banIndex) => {
|
||||
for(let banIndex in channel.banList){
|
||||
//Pull ban from channel ban list
|
||||
const ban = channel.banList[banIndex];
|
||||
|
||||
//ignore permanent and non-expired bans
|
||||
if(ban.expirationDays >= 0 && ban.getDaysUntilExpiration() <= 0){
|
||||
//Get the index of the ban
|
||||
channel.banList.splice(i,1);
|
||||
return await channel.save();
|
||||
channel.banList.splice(banIndex,1);
|
||||
await channel.save();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue