diff --git a/fooocusapi/task_queue.py b/fooocusapi/task_queue.py index 41e2176..4f79e6f 100644 --- a/fooocusapi/task_queue.py +++ b/fooocusapi/task_queue.py @@ -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)