check for ban desync between redis and sql on baninfo

This commit is contained in:
HF 2022-09-22 20:28:37 +02:00
parent 2707fb6123
commit 7dd96fc8f9

View File

@ -9,6 +9,10 @@ import {
getBanInfo, getBanInfo,
unbanIP, unbanIP,
} from '../../data/sql/Ban'; } from '../../data/sql/Ban';
import {
getCacheAllowed,
cleanCacheForIP,
} from '../../data/redis/isAllowedCache';
async function baninfo(req, res, next) { async function baninfo(req, res, next) {
try { try {
@ -21,6 +25,10 @@ async function baninfo(req, res, next) {
const info = await getBanInfo(ip); const info = await getBanInfo(ip);
if (!info) { if (!info) {
const cache = await getCacheAllowed(ip);
if (cache && cache.status === 2) {
cleanCacheForIP(ip);
}
throw new Error(t`You are not banned`); throw new Error(t`You are not banned`);
} }
let sleft = (info.expires) let sleft = (info.expires)