2424celery_app .conf .broker_connection_retry_on_startup = True
2525
2626
27- async def webhook_request (client : AsyncClient , url : str , * , webhook_sig : str , data : dict = None ):
27+ async def webhook_request (client : AsyncClient , url : str , endpoint_id : int , * , webhook_sig : str , data : dict = None ):
2828 """
2929 Send a request to TutorCruncher
3030 :param client
@@ -57,7 +57,9 @@ async def webhook_request(client: AsyncClient, url: str, *, webhook_sig: str, da
5757 else :
5858 app_logger .info ('Request method=%s url=%s status_code=%s' , 'POST' , url , r .status_code , extra = {'data' : data })
5959
60- request_data = RequestData (request_headers = json .dumps (headers ), request_body = json .dumps (data ))
60+ request_data = RequestData (
61+ endpoint_id = endpoint_id , request_headers = json .dumps (headers ), request_body = json .dumps (data )
62+ )
6163 if r is not None :
6264 request_data .response_headers = json .dumps (dict (r .headers ))
6365 request_data .response_body = json .dumps (r .content .decode ())
@@ -107,7 +109,9 @@ async def _async_post_webhooks(endpoints, url_extension, payload):
107109 # Send the Webhook to the endpoint
108110
109111 loaded_payload = json .loads (payload )
110- task = asyncio .ensure_future (webhook_request (client , url , webhook_sig = sig_hex , data = loaded_payload ))
112+ task = asyncio .ensure_future (
113+ webhook_request (client , url , endpoint .id , webhook_sig = sig_hex , data = loaded_payload )
114+ )
111115 tasks .append (task )
112116 webhook_responses = await asyncio .gather (* tasks , return_exceptions = True )
113117 for response in webhook_responses :
@@ -127,7 +131,7 @@ async def _async_post_webhooks(endpoints, url_extension, payload):
127131 # Log the response
128132 webhook_logs .append (
129133 WebhookLog (
130- webhook_endpoint_id = endpoint . id ,
134+ webhook_endpoint_id = response . endpoint_id ,
131135 request_headers = response .request_headers ,
132136 request_body = response .request_body ,
133137 response_headers = response .response_headers ,
0 commit comments