Update app.py
Browse files
app.py
CHANGED
|
@@ -124,25 +124,7 @@ async def task_update(request: Request):
|
|
| 124 |
logging.info(f"WhatsApp API Response: {whatsapp_response.status_code} - {whatsapp_response.text}")
|
| 125 |
|
| 126 |
elif event_type == "taskTagUpdated":
|
| 127 |
-
#
|
| 128 |
-
|
| 129 |
-
if history_items:
|
| 130 |
-
added_tags = history_items[0].get("after", [])
|
| 131 |
-
due_date_timestamp = data.get("task", {}).get("due_date", 0)
|
| 132 |
-
else:
|
| 133 |
-
logging.error("No history items found in taskTagUpdated event.")
|
| 134 |
-
return {"error": "No history items found."}
|
| 135 |
-
|
| 136 |
-
if "missed due date" in added_tags:
|
| 137 |
-
due_date_human = datetime.utcfromtimestamp(int(due_date_timestamp) / 1000).strftime('%Y-%m-%d %H:%M:%S') if due_date_timestamp else "Unknown Date"
|
| 138 |
-
|
| 139 |
-
whatsapp_payload = {
|
| 140 |
-
"chatId": "201092003112@c.us",
|
| 141 |
-
"message": f"⚠️ *Task Overdue!*\n\n📌 *Task:* {task_name}\n⏳ *Due Date:* {due_date_human}\n\n🔗 *View Task:* {task_link}\n\nPlease take action as soon as possible."
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
logging.info(f"Sending Overdue Task Notification: {whatsapp_payload}")
|
| 145 |
-
whatsapp_response = requests.post(WHATSAPP_URL, json=whatsapp_payload, headers=whatsapp_headers)
|
| 146 |
-
logging.info(f"WhatsApp API Response: {whatsapp_response.status_code} - {whatsapp_response.text}")
|
| 147 |
|
| 148 |
return {"status": "Update received"}
|
|
|
|
| 124 |
logging.info(f"WhatsApp API Response: {whatsapp_response.status_code} - {whatsapp_response.text}")
|
| 125 |
|
| 126 |
elif event_type == "taskTagUpdated":
|
| 127 |
+
# Just print the response instead of sending a WhatsApp notification
|
| 128 |
+
logging.info(f"TaskTagUpdated event received: {data}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
return {"status": "Update received"}
|