Added original Todoist link and description in the task note being created.

This commit is contained in:
2025-12-30 09:31:54 +01:00
parent 0b115cd575
commit 22634b8290
+48 -1
View File
@@ -149,6 +149,49 @@ def pick_uid(obj: Dict[str, Any]) -> Optional[str]:
s = str(v).strip() s = str(v).strip()
return s or None return s or None
def todoist_task_url(task: Dict[str, Any]) -> str:
"""
Best-effort URL to the Todoist task.
- If Todoist provides a direct url field, use it.
- Otherwise fall back to the canonical web UI endpoint.
"""
# sometimes present in some payloads (completed/rest)
url = task.get("url") or task.get("task_url") or task.get("taskUrl")
if isinstance(url, str) and url.strip():
return url.strip()
tid = task.get("id")
if tid is None:
return "https://todoist.com/"
return f"https://todoist.com/showTask?id={tid}"
def build_tududi_description_from_todoist(task: Dict[str, Any], task_name: str) -> str:
"""
Tududi description format:
<Task name>
[Todoist task](...)
<Todoist description>
"""
parts: List[str] = []
# Task name (explicit, even if Tududi already has it)
parts.append(task_name.strip())
# Todoist link
tid = task.get("id")
if tid:
parts.append(f"\n[Todoist task](https://todoist.com/showTask?id={tid})")
# Todoist description
td_desc = task.get("description")
if isinstance(td_desc, str) and td_desc.strip():
parts.append("\n" + td_desc.strip())
return "\n\n".join(parts).strip()
# ---------------------------- # ----------------------------
# Todoist client (API v1) # Todoist client (API v1)
@@ -848,6 +891,9 @@ def main() -> None:
project_uid = get_project_uid_for_task(task) project_uid = get_project_uid_for_task(task)
tags = get_tags_for_task(task) tags = get_tags_for_task(task)
# Tududi note: Todoist link + Todoist description
tududi_description = build_tududi_description_from_todoist(task, name)
desc = task.get("description") or "" desc = task.get("description") or ""
comments = comments_idx.get(tid, []) comments = comments_idx.get(tid, [])
desc_extra = comments_to_text(comments) desc_extra = comments_to_text(comments)
@@ -863,7 +909,8 @@ def main() -> None:
due_date=due, due_date=due,
priority=prio, priority=prio,
tags=tags if tags else None, tags=tags if tags else None,
description=desc if desc else None, description=tududi_description,
note=tududi_description,
parent_task_id=tud_parent_id, parent_task_id=tud_parent_id,
is_completed=is_completed if is_completed else None, is_completed=is_completed if is_completed else None,
completed_at=completed_at, completed_at=completed_at,