Kaynağa Gözat

Fix IP cooldown not working

poeti8 6 yıl önce
ebeveyn
işleme
a0dd4f659c
1 değiştirilmiş dosya ile 6 ekleme ve 1 silme
  1. 6 1
      server/db/ip.ts

+ 6 - 1
server/db/ip.ts

@@ -24,9 +24,14 @@ export const addIP = async (ipToGet: string) => {
   return ip;
 };
 export const getIP = async (ip: string) => {
+  const cooldownConfig = Number(process.env.NON_USER_COOLDOWN);
   const matchedIp = await knex<IP>("ips")
     .where({ ip: ip.toLowerCase() })
-    .andWhere("created_at", ">", new Date().toISOString())
+    .andWhere(
+      "created_at",
+      ">",
+      subMinutes(new Date(), cooldownConfig).toISOString()
+    )
     .first();
 
   return matchedIp;