From 3e8dbb59317860704544593991ee408c27fc2fbe Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Tue, 22 Oct 2024 00:37:19 +0500 Subject: [PATCH] reduce default time delta and allowed to be modified with variable --- .env.example | 1 + api.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index cfc8ced..9f4c8e2 100644 --- a/.env.example +++ b/.env.example @@ -8,3 +8,4 @@ QL_0= IBSID= APP_DEBUG=true +TIME_DIFF_LIMIT=1 diff --git a/api.py b/api.py index 6b2d7e0..ccd18c0 100755 --- a/api.py +++ b/api.py @@ -9,6 +9,7 @@ import json from datetime import datetime, timedelta load_dotenv() # This will load environment variables from a .env file if it exists +TIME_DIFF_LIMIT = int(os.getenv('TIME_DIFF_LIMIT', 2)) # Default to 2mins if not set app = Flask(__name__) @@ -36,7 +37,7 @@ def verify_transaction(benef_name, abs_amount, request_time, tx_data_list): if (tx_benef_name == benef_name.strip().lower() and compare_amounts(tx_data['absAmount'], abs_amount) and - time_diff <= timedelta(minutes=30)): + time_diff <= timedelta(minutes=TIME_DIFF_LIMIT)): return True except ValueError as e: app.logger.error(f"Error processing transaction: {str(e)}")