Skip to content

Commit

Permalink
Change webhook reqeust data format
Browse files Browse the repository at this point in the history
  • Loading branch information
konieshadow committed Dec 28, 2023
1 parent 1d8a146 commit 63a0fa8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions fooocusapi/task_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ def finish_task(self, job_id: str):

# Send webhook
if task.is_finished and self.webhook_url:
data = {
"job_id": task.job_id,
"image_url": get_file_serve_url(task.task_result[0].im) if task.task_result else None
}
requests.post(self.webhook_url, json=data)
data = { "job_id": task.job_id, "job_result": [] }
if isinstance(task.task_result, List):
for item in task.task_result:
data["job_result"].append({
"url": get_file_serve_url(item.im) if item.im else None,
"seed": item.seed if item.seed else "-1",
})
try:
res = requests.post(self.webhook_url, json=data)
print(f'Call webhook response status: {res.status_code}')
except Exception as e:
print('Call webhook error:', e)

# Move task to history
self.queue.remove(task)
Expand Down

0 comments on commit 63a0fa8

Please sign in to comment.