Преглед изворни кода

[tasks] Fix loading todoist data from webhook data

Colin Powell пре 8 месеци
родитељ
комит
98924e362e
2 измењених фајлова са 9 додато и 11 уклоњено
  1. 2 2
      vrobbler/apps/scrobbles/scrobblers.py
  2. 7 9
      vrobbler/apps/tasks/webhooks.py

+ 2 - 2
vrobbler/apps/scrobbles/scrobblers.py

@@ -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(

+ 7 - 9
vrobbler/apps/tasks/webhooks.py

@@ -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[