handle sonar bugs

This commit is contained in:
Ean Milligan (Bastion) 2023-05-01 13:57:46 -04:00
parent 1452c7ec44
commit 20008865a7
1 changed files with 24 additions and 22 deletions

View File

@ -27,28 +27,30 @@ const oneDay = oneHour * 24;
const oneWeek = oneDay * 7; const oneWeek = oneDay * 7;
setInterval(() => { setInterval(() => {
const now = new Date().getTime(); const now = new Date().getTime();
joinRequestMap.forEach((joinRequest, key) => { if (joinRequestMap.size) {
switch (joinRequest.status) { joinRequestMap.forEach((joinRequest, key) => {
case JoinRequestStatus.Approved: switch (joinRequest.status) {
// Delete Approved when over 1 hour old case JoinRequestStatus.Approved:
if (joinRequest.timestamp > now - oneHour) { // Delete Approved when over 1 hour old
joinRequestMap.delete(key); if (joinRequest.timestamp > now - oneHour) {
} joinRequestMap.delete(key);
break; }
case JoinRequestStatus.Pending: break;
// Delete Pending when over 1 day old case JoinRequestStatus.Pending:
if (joinRequest.timestamp > now - oneDay) { // Delete Pending when over 1 day old
joinRequestMap.delete(key); if (joinRequest.timestamp > now - oneDay) {
} joinRequestMap.delete(key);
break; }
case JoinRequestStatus.Denied: break;
// Delete Rejected when over 1 week old case JoinRequestStatus.Denied:
if (joinRequest.timestamp > now - oneWeek) { // Delete Rejected when over 1 week old
joinRequestMap.delete(key); if (joinRequest.timestamp > now - oneWeek) {
} joinRequestMap.delete(key);
break; }
} break;
}); }
});
}
// Run cleaner every hour // Run cleaner every hour
}, oneHour); }, oneHour);