Update OTP generation interval, enhance SMS sending functionality, and add age validation for temporary user registration
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m50s

This commit is contained in:
2025-04-19 16:18:45 +05:00
parent f77779a84f
commit c006525aaa
5 changed files with 92 additions and 15 deletions

View File

@ -28,3 +28,30 @@ def send_otp(mobile: str, otp: int, message: str):
else:
logger.debug(f"Failed to send SMS. Status code: {response.status_code}")
return False
def send_sms(mobile: str, message: str):
logger.info(f"Sending SMS to {mobile}")
try:
if not api_url or not api_key:
logger.debug("Failed to send SMS. Missing SMS_API_URL or SMS_API_KEY.")
return False
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
}
data = {
"number": mobile,
"message": message,
"check_delivery": False,
}
response = requests.post(api_url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
return True
else:
logger.debug(f"Failed to send SMS. Status code: {response.status_code}")
return False
except requests.exceptions.RequestException as e:
logger.debug(f"Failed to send SMS. Error: {e}")
return False