(20241214) SMS also ported to the 'tokenKey' system.

This commit is contained in:
2024-12-14 13:02:57 +05:30
parent dc181c4995
commit 364894c2af
4 changed files with 42 additions and 31 deletions
+18 -6
View File
@@ -145,26 +145,38 @@ async def send_sms(
:return: A standard response structure.
"""
# ┏┓
# ┃┃┏┓┏┓┏┓┏┓┏┓┏┏┓┏
# ┣┛┛ ┗ ┣┛┛ ┗┛┗┗ ┛┛
# ┛
# ┏┓ ┓ ┏┓┓ ┓
# ┣┫┓┏╋┣┓ ┃ ┣┓┏┓┏┃
# ┛┗┗┻┗┛┗ ┗┛┗┗ ┗┛┗
# If the session token is invalid/expired:
if kwargs.get("session_info") is None:
return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED
http_code = HttpCodes.UNAUTHORIZED,
message = "invalid session"
)
# ┏┓ ┓ ┏┳┓┓ ┏┓┳┳┓┏┓
# ┗┓┏┓┏┓┏┫ ┃ ┣┓┏┓ ┗┓┃┃┃┗┓
# ┗┛┗ ┛┗┗┻ ┻ ┛┗┗ ┗┛┛ ┗┗┛
# Get the token from the token key:
auth_token = await current_app.mail_controller.get_token(
mongo_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
)
if auth_token is None: return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
message = f"no such token key"
)
# Send the SMS:
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,
auth_token = auth_token,
messages = inbound_data.message
)