Update app.py
Browse files
app.py
CHANGED
|
@@ -218,50 +218,48 @@ async def create_task(request: Request):
|
|
| 218 |
clickup_response = requests.post(create_url, headers=headers, json=payload)
|
| 219 |
clickup_data = clickup_response.json()
|
| 220 |
print(f"ClickUp Response: {clickup_response.status_code}, {clickup_data}")
|
| 221 |
-
|
| 222 |
-
# After task creation and response
|
| 223 |
-
new_task_id = clickup_data.get("id")
|
| 224 |
-
space_id = clickup_data.get("space", {}).get("id")
|
| 225 |
-
assignee_ids = [str(uid) for uid in assignee_ids] # already known
|
| 226 |
-
|
| 227 |
-
# Notify each assignee
|
| 228 |
-
for assignee_id in assignee_ids:
|
| 229 |
-
params = {
|
| 230 |
-
"mode": "notify-assigned",
|
| 231 |
-
"assigneeId": assignee_id,
|
| 232 |
-
"spaceId": space_id
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
response = requests.get(web_app_url, params=params)
|
| 236 |
-
print(f"Assingnee to notify {response.json()}")
|
| 237 |
-
if response.ok:
|
| 238 |
-
phone = response.json().get("phone")
|
| 239 |
-
if phone and phone != "not-found":
|
| 240 |
-
chat_id = f"{phone}@c.us"
|
| 241 |
-
task_url = f"https://app.clickup.com/t/{new_task_id}"
|
| 242 |
-
task_name = payload["name"]
|
| 243 |
-
due_date = payload.get("due_date")
|
| 244 |
-
if due_date:
|
| 245 |
-
due_str = datetime.utcfromtimestamp(due_date / 1000).strftime('%Y-%m-%d')
|
| 246 |
-
msg = (
|
| 247 |
-
f"📌 *تم تعيين مهمة جديدة لك!*\n\n"
|
| 248 |
-
f"📝 *اسم المهمة:* {task_name}\n"
|
| 249 |
-
f"📅 *تاريخ التسليم:* {due_str}\n"
|
| 250 |
-
f"🔗 *رابط المهمة:* {task_url}"
|
| 251 |
-
)
|
| 252 |
-
else:
|
| 253 |
-
msg = (
|
| 254 |
-
f"📌 *تم تعيين مهمة جديدة لك!*\n\n"
|
| 255 |
-
f"📝 *اسم المهمة:* {task_name}\n"
|
| 256 |
-
f"🔗 *رابط المهمة:* {task_url}"
|
| 257 |
-
)
|
| 258 |
-
send_whatsapp_notification(chat_id, msg)
|
| 259 |
-
|
| 260 |
-
else:
|
| 261 |
-
logging.warning(f"❌ Couldn't fetch phone number for assignee {assignee_id}")
|
| 262 |
-
|
| 263 |
|
| 264 |
return {"status": "Standard task created", "clickup": clickup_data}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
else:
|
| 267 |
return {"error": f"Unsupported task type: {task_type}"}
|
|
|
|
| 218 |
clickup_response = requests.post(create_url, headers=headers, json=payload)
|
| 219 |
clickup_data = clickup_response.json()
|
| 220 |
print(f"ClickUp Response: {clickup_response.status_code}, {clickup_data}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
return {"status": "Standard task created", "clickup": clickup_data}
|
| 223 |
+
# After task creation and response
|
| 224 |
+
new_task_id = clickup_data.get("id")
|
| 225 |
+
space_id = clickup_data.get("space", {}).get("id")
|
| 226 |
+
assignee_ids = [str(uid) for uid in assignee_ids] # already known
|
| 227 |
+
|
| 228 |
+
# Notify each assignee
|
| 229 |
+
for assignee_id in assignee_ids:
|
| 230 |
+
params = {
|
| 231 |
+
"mode": "notify-assigned",
|
| 232 |
+
"assigneeId": assignee_id,
|
| 233 |
+
"spaceId": space_id
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
response = requests.get(web_app_url, params=params)
|
| 237 |
+
print(f"Assingnee to notify {response.json()}")
|
| 238 |
+
if response.ok:
|
| 239 |
+
phone = response.json().get("phone")
|
| 240 |
+
if phone and phone != "not-found":
|
| 241 |
+
chat_id = f"{phone}@c.us"
|
| 242 |
+
task_url = f"https://app.clickup.com/t/{new_task_id}"
|
| 243 |
+
task_name = payload["name"]
|
| 244 |
+
due_date = payload.get("due_date")
|
| 245 |
+
if due_date:
|
| 246 |
+
due_str = datetime.utcfromtimestamp(due_date / 1000).strftime('%Y-%m-%d')
|
| 247 |
+
msg = (
|
| 248 |
+
f"📌 *تم تعيين مهمة جديدة لك!*\n\n"
|
| 249 |
+
f"📝 *اسم المهمة:* {task_name}\n"
|
| 250 |
+
f"📅 *تاريخ التسليم:* {due_str}\n"
|
| 251 |
+
f"🔗 *رابط المهمة:* {task_url}"
|
| 252 |
+
)
|
| 253 |
+
else:
|
| 254 |
+
msg = (
|
| 255 |
+
f"📌 *تم تعيين مهمة جديدة لك!*\n\n"
|
| 256 |
+
f"📝 *اسم المهمة:* {task_name}\n"
|
| 257 |
+
f"🔗 *رابط المهمة:* {task_url}"
|
| 258 |
+
)
|
| 259 |
+
send_whatsapp_notification(chat_id, msg)
|
| 260 |
+
|
| 261 |
+
else:
|
| 262 |
+
logging.warning(f"❌ Couldn't fetch phone number for assignee {assignee_id}")
|
| 263 |
|
| 264 |
else:
|
| 265 |
return {"error": f"Unsupported task type: {task_type}"}
|