Merge remote-tracking branch 'origin/master'

This commit is contained in:
yatmesh
2025-04-29 18:01:04 +05:30
11 changed files with 776 additions and 148 deletions
+55 -25
View File
@@ -291,7 +291,7 @@ async def generate_otp(
@handle_cancelled_request()
async def verify_otp(
inbound_headers: dict = None,
inbound_data: dict | VerifyTimedOTP = None,
inbound_data: dict | VerifyTimedOTPRequestData = None,
inbound_files: dict = None,
**kwargs
):
@@ -350,35 +350,65 @@ async def verify_otp(
# ┣┫┏┫┏┫ ┃ ┃┓┏┓┏┓╋ ┃┃┃┓╋┣┓ ┃┃┏┓╋┏┓┏
# ┛┗┗┻┗┻ ┗┛┗┗┗ ┛┗┗ ┗┻┛┗┗┛┗ ┛┗┗┛┗┗ ┛
# Fix the phone no. to have the country code:
# Fix the phone no. to have the country code:
phone_no = regex.replace(
text = inbound_data.phoneNo,
pattern = r"[^\d]",
substitute_text = ""
)
if not phone_no.startswith("254"): phone_no = "254" + phone_no
phone_no = "+" + phone_no
if phone_no.startswith("254"): phone_no = phone_no[3:]
if phone_no.startswith("0"): phone_no = phone_no[1:]
phone_no = "+254" + phone_no
# hit Omkar's API:
api_response = await current_app.http_client.post(
url = "https://api.thecaoffice.com/client/add/with/notes",
headers = {"X-Session-Token": inbound_headers["X-Session-Token"]},
json = {
"email": inbound_data.email,
"clientName": inbound_data.username,
"address": None,
"phoneNo": phone_no,
"city": None,
"pincode": None,
"panCard": None,
"gst": None,
"entity": None,
"country": None,
"startDate": None,
"period": None,
"amount": None
}
)
# Do this when the user is trying a new sign-up:
# Hit Omkar's API:
if inbound_data.isSignup:
api_response = await current_app.http_client.post(
url = "https://api.thecaoffice.com/client/add/with/notes",
headers = {"X-Session-Token": inbound_headers["X-Session-Token"]},
json = {
"email": inbound_data.email,
"clientName": inbound_data.username,
"password": inbound_data.password,
"address": None,
"phoneNo": phone_no,
"city": None,
"pincode": None,
"panCard": None,
"gst": None,
"entity": None,
"country": None,
"startDate": None,
"period": None,
"amount": None
}
)
# When this is not a new sign-up. it is a password reset request:
# Hit Omkar's API:
else:
api_response = await current_app.http_client.post(
url = "https://api.thecaoffice.com/client/update/with/notes",
headers = {"X-Session-Token": inbound_headers["X-Session-Token"]},
json = {
"idClient": inbound_data.idClient,
"email": inbound_data.email,
"clientName": inbound_data.clientName,
"username": inbound_data.username,
"password": inbound_data.password,
"address": inbound_data.address,
"phoneNo": phone_no,
"city": inbound_data.city,
"pincode": inbound_data.pincode,
"panCard": inbound_data.panCard,
"gst": inbound_data.gst,
"entity": inbound_data.entity,
"country": inbound_data.country,
"startDate": inbound_data.startDate,
"period": inbound_data.period,
"amount": inbound_data.amount
}
)
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
@@ -389,7 +419,7 @@ async def verify_otp(
success = api_response.is_success
return ResponseModel(
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if success else HttpCodes.UNAUTHORIZED
http_code = HttpCodes.SUCCESS if success else HttpCodes.UNAUTHORIZED,
)
@@ -193,8 +193,17 @@ async def list_mails(
if inbound_data.tags: additional_filter["tags"] = {"$in": inbound_data.tags}
additional_filter = additional_filter or None
# Get the mails:
mails_list = await current_app.mail_controller.list_mails(
# # Get the mails:
# mails_list = await current_app.mail_controller.list_mails(
# mongo_data_conn = current_app.data_mongo,
# token_ids = token_ids,
# limit = inbound_data.count,
# skip = inbound_data.fromCount,
# additional_filter = additional_filter
# )
# Because someone wanted all sorts of messages in one place so fucking be it:
mails_list = await current_app.core_message_controller.get_message_previews(
mongo_data_conn = current_app.data_mongo,
token_ids = token_ids,
limit = inbound_data.count,
+10 -3
View File
@@ -66,7 +66,7 @@ from utils_v2.goog.controllers.gmail.gmail_client import AsyncGmailClient
from utils_v2.whatsapp.nimbus.controllers.async_nimbus_whatsapp import AsyncNimbusWhatsapp
# Core Controller Models:
from controllers.core.message import CoreMessageController
# from controllers.core.message import CoreMessageController
# from controllers.core.auth_token import CoreAuthTokenController
from controllers.core.ai.llm import CoreLLMController
from controllers.core.payment import CorePaymentController
@@ -78,6 +78,7 @@ from controllers.core.payment import CorePaymentController
# Controllers V2:
from controllers_v2.core.auth_token import CoreAuthTokenController
from controllers_v2.core.message import CoreMessageController
# ---
from controllers_v2.message.sms.all_sms import AllSMSController
from controllers_v2.message.sms.nimbus_sms_india import NimbusSMSIndiaController
@@ -465,14 +466,20 @@ async def app_startup(**kwargs):
# ┃ ┏┓┏┓╋┏┓┏┓┃┃┏┓┏┓┏ ┃┃┏┛
# ┗┛┗┛┛┗┗┛ ┗┛┗┗┗ ┛ ┛ ┗┛┗━
# Auth-Token Controller(s):
# Core Controller(s):
current_app.core_auth_token_controller = CoreAuthTokenController(
cache = current_app.module_cache,
http_client = current_app.http_client,
alert_url = current_app.script_data["alerts"]["url"],
debug = enable_debugging
)
current_app.printer("Auth-Token (C) ready.")
current_app.core_message_controller = CoreMessageController(
cache = current_app.module_cache,
http_client = current_app.http_client,
alert_url = current_app.script_data["alerts"]["url"],
debug = enable_debugging
)
current_app.printer("Core (C) ready.")
# Messages / SMS Controllers:
current_app.sms_controller = AllSMSController(