[tasks] Fix loading todoist data from webhook data

This commit is contained in:
2024-10-15 14:35:19 -04:00
parent 0384f72cbd
commit 98924e362e
2 changed files with 9 additions and 11 deletions

View File

@ -312,8 +312,8 @@ def manual_scrobble_from_url(url: str, user_id: int) -> Scrobble:
def todoist_scrobble_task_finish(todoist_task: dict, user_id: int) -> Scrobble:
scrobble = Scrobble.objects.filter(
user_id=user_id, logdata__todoist_id=todoist_task.get("todoist_id")
)
user_id=user_id, log__todoist_id=todoist_task.get("todoist_id")
).first()
if not scrobble.in_progress or scrobble.played_to_completion:
logger.warning(

View File

@ -23,19 +23,17 @@ def todoist_webhook(request):
"[todoist_webhook] called",
extra={"post_data": post_data},
)
# ["inprogress","project","work"],
# :item:updated,
todoist_type, todoist_event = post_data.get("event_name").split(":")
event_data = post_data.get("event_data", {})
todoist_task = {
"todoist_id": post_data.get("id"),
"todoist_label_list": post_data.get("event_data", {}).get("labels"),
"todoist_id": event_data.get("id"),
"todoist_label_list": event_data.get("labels"),
"todoist_type": todoist_type,
"todoist_event": todoist_event,
"title": post_data.get("content"),
"description": post_data.get("description"),
"timestamp_utc": pendulum.parse(
post_data.get("event_data", {}).get("updated_at")
),
"todoist_project_id": event_data.get("project_id"),
"description": event_data.get("content"),
"details": event_data.get("description"),
"timestamp_utc": pendulum.parse(event_data.get("updated_at")),
}
if todoist_task["todoist_type"] != "item" or todoist_task[