(20241213) SMS Auth reworked.
This commit is contained in:
@@ -63,8 +63,8 @@ from utils_v2.api.async_quart import (
|
||||
from shared import constants
|
||||
|
||||
# Data Models:
|
||||
from models.data.api.sms.auth import SMSAuthRequestHeaders, SMSAuthRequestData
|
||||
from models.data.core.auth_token import CoreAuthTokenModel
|
||||
from models.api.sms.auth import SMSAuthRequestHeaders, SMSAuthRequestData
|
||||
from models.core.auth_token import CoreAuthTokenModel
|
||||
|
||||
# For asynchronous activities:
|
||||
import asyncio
|
||||
@@ -158,7 +158,7 @@ async def authorize_sms_client(
|
||||
)
|
||||
|
||||
# Start by assuming failure:
|
||||
token_id = None
|
||||
success = False
|
||||
|
||||
# ┏┓ ┳┓• ┓ ┏┓┳┳┓┏┓ ┳ ┓•
|
||||
# ┣ ┏┓┏┓ ┃┃┓┏┳┓┣┓┓┏┏ ┗┓┃┃┃┗┓ ┃┏┓┏┫┓┏┓
|
||||
@@ -166,7 +166,7 @@ async def authorize_sms_client(
|
||||
|
||||
if inbound_data.smsClient == "nimbusSmsIndia":
|
||||
|
||||
token_id = await current_app.sms_auth_model.set(
|
||||
success = await current_app.sms_controller.set_token(
|
||||
db_conn = current_app.sql_writer,
|
||||
mongo_conn = current_app.data_mongo,
|
||||
auth_token = CoreAuthTokenModel(
|
||||
@@ -183,17 +183,6 @@ async def authorize_sms_client(
|
||||
status = "active",
|
||||
syncFreq = 60
|
||||
),
|
||||
# user_info = kwargs["session_info"],
|
||||
# client_user_id = {
|
||||
# "userId": inbound_data.auth.userId,
|
||||
# "senderId": inbound_data.auth.senderId,
|
||||
# "entityId": inbound_data.auth.entityId
|
||||
# },
|
||||
# auth = inbound_data.auth.model_dump(),
|
||||
# token = None,
|
||||
# service_client = inbound_data.smsClient,
|
||||
# auth_type = "auth",
|
||||
# sync_freq = 300,
|
||||
session_token = inbound_headers["X-Session-Token"]
|
||||
)
|
||||
|
||||
@@ -204,10 +193,10 @@ async def authorize_sms_client(
|
||||
|
||||
elif inbound_data.smsClient == "savvyBulkSmsKenya":
|
||||
|
||||
token_id = await current_app.sms_auth_model.set(
|
||||
success = await current_app.sms_controller.set_token(
|
||||
db_conn = current_app.sql_writer,
|
||||
mongo_conn = current_app.data_mongo,
|
||||
auth_token=CoreAuthTokenModel(
|
||||
auth_token = CoreAuthTokenModel(
|
||||
serviceType = "sms",
|
||||
client = inbound_data.smsClient,
|
||||
authType = "auth",
|
||||
@@ -220,16 +209,6 @@ async def authorize_sms_client(
|
||||
status = "active",
|
||||
syncFreq = 60
|
||||
),
|
||||
# user_info = kwargs["session_info"],
|
||||
# client_user_id = {
|
||||
# "partnerId": inbound_data.auth.partnerId,
|
||||
# "shortCode": inbound_data.auth.shortCode
|
||||
# },
|
||||
# auth = inbound_data.auth.model_dump(),
|
||||
# token = None,
|
||||
# service_client = inbound_data.smsClient,
|
||||
# auth_type = "auth",
|
||||
# sync_freq = 300,
|
||||
session_token = inbound_headers["X-Session-Token"]
|
||||
)
|
||||
|
||||
@@ -240,11 +219,11 @@ async def authorize_sms_client(
|
||||
|
||||
# Done here:
|
||||
return ResponseModel(
|
||||
status_code = StatusCodes.OK if token_id else StatusCodes.FAILED,
|
||||
http_code = HttpCodes.SUCCESS if token_id else HttpCodes.INTERNAL_SERVER_ERROR,
|
||||
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
|
||||
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
|
||||
data = {
|
||||
"client": inbound_data.smsClient,
|
||||
"authorized": True
|
||||
"authorized": success
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ from utils_v2.api.async_quart import (
|
||||
)
|
||||
|
||||
# Data Models:
|
||||
from models.data.api.sms.send import SMSSendRequestHeaders, SMSSendRequestData
|
||||
from models.data.core.auth_token import CoreAuthTokenModel
|
||||
from models.core.auth_token import CoreAuthTokenModel
|
||||
from models.api.sms.send import SMSSendRequestHeaders, SMSSendRequestData
|
||||
|
||||
# Common:
|
||||
from shared import constants
|
||||
@@ -174,13 +174,13 @@ async def send_sms(
|
||||
# ┗┓┏┓┏┓┏┫ ┃ ┣┓┏┓ ┗┓┃┃┃┗┓
|
||||
# ┗┛┗ ┛┗┗┻ ┻ ┛┗┗ ┗┛┛ ┗┗┛
|
||||
|
||||
client_response = await current_app.sms_send_model.send_sms(
|
||||
mongo_conn = current_app.data_mongo,
|
||||
token_id = inbound_data.tokenId,
|
||||
auth_token = auth_token,
|
||||
inbound_data = inbound_data,
|
||||
session_token = inbound_headers["X-Session-Token"]
|
||||
)
|
||||
# client_response = await current_app.sms_send_model.send_sms(
|
||||
# mongo_conn = current_app.data_mongo,
|
||||
# token_id = inbound_data.tokenId,
|
||||
# auth_token = auth_token,
|
||||
# inbound_data = inbound_data,
|
||||
# session_token = inbound_headers["X-Session-Token"]
|
||||
# )
|
||||
|
||||
# ┳┓
|
||||
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
|
||||
|
||||
Reference in New Issue
Block a user