Compare commits

...

1 Commits

Author SHA1 Message Date
khushalps f0875a565a (20260623) Something in token notes. Okay bye. 2026-06-23 18:08:00 +05:30
2 changed files with 33 additions and 4 deletions
+3 -1
View File
@@ -245,7 +245,9 @@ async def callback_test(
), ),
token_notes = { token_notes = {
"apiKey": inbound_data.auth.apiKey, "apiKey": inbound_data.auth.apiKey,
"senderId": inbound_data.auth.senderId "senderId": inbound_data.auth.senderId,
"lastSuccess": None,
"lastFailure": None,
}, },
display_name = inbound_data.auth.senderId, display_name = inbound_data.auth.senderId,
display_picture = None, display_picture = None,
+30 -3
View File
@@ -69,6 +69,7 @@ import asyncio
# Common: # Common:
from shared import constants from shared import constants
# ***************************************************************************************************************** # *****************************************************************************************************************
# ***** **** # ***** ****
# *** MACROS / ONE-TIME INIT *** # *** MACROS / ONE-TIME INIT ***
@@ -225,8 +226,10 @@ class WhatsAppNimbusController(ChatController):
) )
self._printer(message_id, client_response.success) self._printer(message_id, client_response.success)
# Done here: # Check for success:
success = True if client_response.success and message_id else False success = True if client_response.success and message_id else False
# Done here:
return ChatSendOneResult( return ChatSendOneResult(
success = success, success = success,
message = "Message sent successfully." if client_response.success else "Message sending failed.", message = "Message sent successfully." if client_response.success else "Message sending failed.",
@@ -290,13 +293,37 @@ class WhatsAppNimbusController(ChatController):
individual_results = await asyncio.gather(*tasks) individual_results = await asyncio.gather(*tasks)
# Prepare the final result: # Prepare the final result:
last_success = None
last_failure = None
for result in individual_results: for result in individual_results:
if result.success: cumulative_results.successCount += 1 if result.success:
else: cumulative_results.failureCount += 1 cumulative_results.successCount += 1
last_success = result.chatMessage.message["apiMessage"]
else:
cumulative_results.failureCount += 1
last_failure = result.chatMessage.message["apiMessage"]
cumulative_results.totalCount += 1 cumulative_results.totalCount += 1
cumulative_results.chatMessages.append(result.chatMessage) cumulative_results.chatMessages.append(result.chatMessage)
cumulative_results.message = f"{cumulative_results.successCount}/{cumulative_results.totalCount} messgae(s) sent." cumulative_results.message = f"{cumulative_results.successCount}/{cumulative_results.totalCount} messgae(s) sent."
# Fuck this, fuck that, fuck everything:
await self.set_token(
sql_conn = sql_conn,
mongo_data_conn = mongo_data_conn,
token_key = auth_token.key,
auth_token = auth_token,
token_notes = {
"apiKey": auth_token.auth["apiKey"],
"senderId": auth_token.auth["senderId"],
"lastSuccess": last_success,
"lastFailure": last_failure,
},
display_name = auth_token.clientDisplayName,
display_picture = None,
last_action = "Auth Granted",
session_token = None
)
# Done here: # Done here:
return cumulative_results return cumulative_results