(20241213) SMS sending ready.

This commit is contained in:
2024-12-13 19:44:22 +05:30
parent f47e81c411
commit 8c01ca5135
6 changed files with 104 additions and 36 deletions
+15 -23
View File
@@ -157,30 +157,16 @@ async def send_sms(
http_code = HttpCodes.UNAUTHORIZED
)
# Fetch the auth-token to use to send this message:
auth_token = await current_app.sms_auth_model.get(
mongo_conn = current_app.data_mongo,
token_id = inbound_data.tokenId
)
# If no auth-token was found, we return with failure:
if not auth_token: return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.BAD_REQUEST,
message = f"no such token id"
)
# ┏┓ ┓ ┏┳┓┓ ┏┓┳┳┓┏┓
# ┗┓┏┓┏┓┏┫ ┃ ┣┓┏┓ ┗┓┃┃┃┗┓
# ┗┛┗ ┛┗┗┻ ┻ ┛┗┗ ┗┛┛ ┗┗┛
# 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_controller.send(
mongo_conn = current_app.data_mongo,
http_client = current_app.http_client,
token_id = inbound_data.tokenId,
messages = inbound_data.message
)
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
@@ -188,10 +174,16 @@ async def send_sms(
# ┛
# Done here:
success = True if client_response.successCount else False
return ResponseModel(
status_code = StatusCodes.OK if client_response.success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if client_response.success else HttpCodes.INTERNAL_SERVER_ERROR,
message = None if client_response.success else f"SMS Client: {client_response.brief}"
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
data = {
"successCount": client_response.successCount,
"failureCount": client_response.failureCount,
"totalCount": client_response.totalCount,
},
message = client_response.message
)