[task] Log when we don't find a task for notes
This commit is contained in:
@ -327,21 +327,31 @@ def todoist_scrobble_update_task(
|
|||||||
log__task_id=todoist_note.get("task_id"),
|
log__task_id=todoist_note.get("task_id"),
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if scrobble:
|
if not scrobble:
|
||||||
existing_notes = scrobble.log.get("notes", {})
|
|
||||||
existing_notes[todoist_note.get("todoist_id")] = todoist_note.get(
|
|
||||||
"content"
|
|
||||||
)
|
|
||||||
scrobble.log["notes"] = existing_notes
|
|
||||||
scrobble.save(update_fields=["log"])
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"[todoist_scrobble_update_task] todoist note added",
|
"[todoist_scrobble_update_task] no task found",
|
||||||
extra={
|
extra={
|
||||||
"todoist_note": todoist_note,
|
"todoist_note": todoist_note,
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"media_type": Scrobble.MediaType.TASK,
|
"media_type": Scrobble.MediaType.TASK,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
existing_notes = scrobble.log.get("notes", {})
|
||||||
|
existing_notes[todoist_note.get("todoist_id")] = todoist_note.get(
|
||||||
|
"content"
|
||||||
|
)
|
||||||
|
scrobble.log["notes"] = existing_notes
|
||||||
|
scrobble.save(update_fields=["log"])
|
||||||
|
logger.info(
|
||||||
|
"[todoist_scrobble_update_task] todoist note added",
|
||||||
|
extra={
|
||||||
|
"todoist_note": todoist_note,
|
||||||
|
"user_id": user_id,
|
||||||
|
"media_type": Scrobble.MediaType.TASK,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
return scrobble
|
return scrobble
|
||||||
|
|
||||||
|
|||||||
@ -103,6 +103,10 @@ def todoist_webhook(request):
|
|||||||
scrobble = todoist_scrobble_update_task(todoist_note, user_id)
|
scrobble = todoist_scrobble_update_task(todoist_note, user_id)
|
||||||
|
|
||||||
if not scrobble:
|
if not scrobble:
|
||||||
|
logger.info(
|
||||||
|
"[todoist_webhook] finished with no note or task found",
|
||||||
|
extra={"scrobble_id": None},
|
||||||
|
)
|
||||||
return Response(
|
return Response(
|
||||||
{"error": "No scrobble found to be updated"},
|
{"error": "No scrobble found to be updated"},
|
||||||
status=status.HTTP_304_NOT_MODIFIED,
|
status=status.HTTP_304_NOT_MODIFIED,
|
||||||
|
|||||||
Reference in New Issue
Block a user