Update app.py
Browse files
app.py
CHANGED
|
@@ -331,22 +331,24 @@ async def task_update(request: Request):
|
|
| 331 |
notify_map = response.json()
|
| 332 |
print("✅ Notify Map:", notify_map)
|
| 333 |
|
| 334 |
-
# ✅ Extract and
|
| 335 |
-
|
| 336 |
manager_numbers = notify_map.get("managers", [])
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
# ✅ Get assignee names from
|
| 342 |
user_names = [
|
| 343 |
assignee_id_to_name.get(user_id, f"User {user_id}")
|
| 344 |
-
for user_id in
|
| 345 |
]
|
| 346 |
assignee_name_str = "، ".join(user_names)
|
| 347 |
-
|
|
|
|
|
|
|
| 348 |
print("👥 Assignee Name(s) for Manager Message:", assignee_name_str)
|
| 349 |
-
|
| 350 |
# ✅ Arabic WhatsApp messages
|
| 351 |
user_message = (
|
| 352 |
f"⚠️ *تنبيه بتأخر المهمة!*\n\n"
|
|
@@ -365,12 +367,10 @@ async def task_update(request: Request):
|
|
| 365 |
f"يرجى المتابعة مع الفريق."
|
| 366 |
)
|
| 367 |
|
| 368 |
-
# ✅ Loop and send to users
|
| 369 |
for num in user_numbers:
|
| 370 |
chat_id = f"{num}@c.us"
|
| 371 |
send_whatsapp_notification(chat_id, user_message)
|
| 372 |
|
| 373 |
-
# ✅ Loop and send to managers
|
| 374 |
for num in manager_numbers:
|
| 375 |
chat_id = f"{num}@c.us"
|
| 376 |
send_whatsapp_notification(chat_id, manager_message)
|
|
|
|
| 331 |
notify_map = response.json()
|
| 332 |
print("✅ Notify Map:", notify_map)
|
| 333 |
|
| 334 |
+
# ✅ Extract user and manager numbers
|
| 335 |
+
user_dict = notify_map.get("users", {})
|
| 336 |
manager_numbers = notify_map.get("managers", [])
|
| 337 |
|
| 338 |
+
# ✅ Get unique user numbers
|
| 339 |
+
user_numbers = list(user_dict.values())
|
| 340 |
+
|
| 341 |
+
# ✅ Get assignee names from user_dict keys (user IDs)
|
| 342 |
user_names = [
|
| 343 |
assignee_id_to_name.get(user_id, f"User {user_id}")
|
| 344 |
+
for user_id in user_dict.keys()
|
| 345 |
]
|
| 346 |
assignee_name_str = "، ".join(user_names)
|
| 347 |
+
|
| 348 |
+
print("📞 User Numbers:", user_numbers)
|
| 349 |
+
print("👨💼 Manager Numbers:", manager_numbers)
|
| 350 |
print("👥 Assignee Name(s) for Manager Message:", assignee_name_str)
|
| 351 |
+
|
| 352 |
# ✅ Arabic WhatsApp messages
|
| 353 |
user_message = (
|
| 354 |
f"⚠️ *تنبيه بتأخر المهمة!*\n\n"
|
|
|
|
| 367 |
f"يرجى المتابعة مع الفريق."
|
| 368 |
)
|
| 369 |
|
|
|
|
| 370 |
for num in user_numbers:
|
| 371 |
chat_id = f"{num}@c.us"
|
| 372 |
send_whatsapp_notification(chat_id, user_message)
|
| 373 |
|
|
|
|
| 374 |
for num in manager_numbers:
|
| 375 |
chat_id = f"{num}@c.us"
|
| 376 |
send_whatsapp_notification(chat_id, manager_message)
|