59e26b28 by Jonille Arreglo

31466_limited_usage_chatbot+

1 parent 80f3ea39
Showing 1 changed file with 9 additions and 6 deletions
...@@ -435,12 +435,13 @@ async function validation (aiwp_app_id, req, res) { ...@@ -435,12 +435,13 @@ async function validation (aiwp_app_id, req, res) {
435 res.json({ status: "invalid", restrict: true, redirect: auth.redirect }); 435 res.json({ status: "invalid", restrict: true, redirect: auth.redirect });
436 res.end(); 436 res.end();
437 return false; 437 return false;
438 } else if (typeof auth.has_pro_access === "undefined" && !auth.has_pro_access) { 438 } else if (auth.subscription_type &&
439 typeof auth.has_pro_access === "undefined" && !auth.has_pro_access) {
439 res.json({ status: "invalid", restrict: true }); 440 res.json({ status: "invalid", restrict: true });
440 res.end(); 441 res.end();
441 return false; 442 return false;
442 } 443 }
443 } 444 } else {
444 let data = await getUsage({ 445 let data = await getUsage({
445 aiwp_logged_in, app: 'chatbot+' 446 aiwp_logged_in, app: 'chatbot+'
446 }); 447 });
...@@ -450,8 +451,11 @@ async function validation (aiwp_app_id, req, res) { ...@@ -450,8 +451,11 @@ async function validation (aiwp_app_id, req, res) {
450 res.status(200); 451 res.status(200);
451 return false; 452 return false;
452 } 453 }
454 }
453 } else { 455 } else {
454 IS_FREE_USER = true; 456 IS_FREE_USER = true;
457 }
458 if(IS_FREE_USER) {
455 let data = await getLimitedUsage({ 459 let data = await getLimitedUsage({
456 "aiwp_app_id": aiwp_app_id 460 "aiwp_app_id": aiwp_app_id
457 }); 461 });
...@@ -459,14 +463,13 @@ async function validation (aiwp_app_id, req, res) { ...@@ -459,14 +463,13 @@ async function validation (aiwp_app_id, req, res) {
459 if (data.usage !== null) { 463 if (data.usage !== null) {
460 TRIED_USAGE = parseInt(data.usage); 464 TRIED_USAGE = parseInt(data.usage);
461 } 465 }
462 466 if (TRIED_USAGE >= limit) {
463 }
464 if (IS_FREE_USER && TRIED_USAGE >= limit) {
465 res.json({ status: "invalid", limited: true }); 467 res.json({ status: "invalid", limited: true });
466 res.end(); 468 res.end();
467 return false; 469 return false;
468 } 470 }
469 if (IS_FREE_USER) TRIED_USAGE++; 471 TRIED_USAGE++;
472 }
470 473
471 return { IS_FREE_USER, aiwp_logged_in, TRIED_USAGE }; 474 return { IS_FREE_USER, aiwp_logged_in, TRIED_USAGE };
472 }; 475 };
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!