Fix halal usage Infinity bug, all endpoints passing
This commit is contained in:
@@ -81,18 +81,20 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
if (!usage) {
|
||||
const queryLimit = limits.queriesPerDay === Infinity ? 999999 : limits.queriesPerDay;
|
||||
usage = await prisma.halalUsage.create({
|
||||
data: {
|
||||
userId: user.id,
|
||||
queriesUsed: 0,
|
||||
queriesLimit: limits.queriesPerDay,
|
||||
queriesLimit: queryLimit,
|
||||
periodEnd: new Date(now.getTime() + 24 * 60 * 60 * 1000),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Check if allowed
|
||||
if (usage.queriesUsed >= usage.queriesLimit && limits.queriesPerDay !== Infinity) {
|
||||
const effectiveLimit = limits.queriesPerDay === Infinity ? 999999 : usage.queriesLimit;
|
||||
if (usage.queriesUsed >= effectiveLimit && limits.queriesPerDay !== Infinity) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
allowed: false,
|
||||
|
||||
Reference in New Issue
Block a user