mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 12:20:38 +08:00
Handle marketplace hook
This commit is contained in:
@ -24,19 +24,7 @@ async def handle_github_webhooks(request: Request, response: Response):
|
|||||||
"""
|
"""
|
||||||
logging.debug("Received a GitHub webhook")
|
logging.debug("Received a GitHub webhook")
|
||||||
|
|
||||||
try:
|
body = await get_body(request)
|
||||||
body = await request.json()
|
|
||||||
except Exception as e:
|
|
||||||
logging.error("Error parsing request body", e)
|
|
||||||
raise HTTPException(status_code=400, detail="Error parsing request body") from e
|
|
||||||
|
|
||||||
body_bytes = await request.body()
|
|
||||||
signature_header = request.headers.get('x-hub-signature-256', None)
|
|
||||||
|
|
||||||
webhook_secret = getattr(settings.github, 'webhook_secret', None)
|
|
||||||
|
|
||||||
if webhook_secret:
|
|
||||||
verify_signature(body_bytes, webhook_secret, signature_header)
|
|
||||||
|
|
||||||
logging.debug(f'Request body:\n{body}')
|
logging.debug(f'Request body:\n{body}')
|
||||||
installation_id = body.get("installation", {}).get("id")
|
installation_id = body.get("installation", {}).get("id")
|
||||||
@ -45,6 +33,27 @@ async def handle_github_webhooks(request: Request, response: Response):
|
|||||||
return await handle_request(body)
|
return await handle_request(body)
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/api/v1/marketplace_webhooks")
|
||||||
|
async def handle_marketplace_webhooks(request: Request, response: Response):
|
||||||
|
body = await get_body(request)
|
||||||
|
logging.info(f'Request body:\n{body}')
|
||||||
|
|
||||||
|
async def get_body(request):
|
||||||
|
try:
|
||||||
|
body = await request.json()
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error parsing request body", e)
|
||||||
|
raise HTTPException(status_code=400, detail="Error parsing request body") from e
|
||||||
|
body_bytes = await request.body()
|
||||||
|
signature_header = request.headers.get('x-hub-signature-256', None)
|
||||||
|
webhook_secret = getattr(settings.github, 'webhook_secret', None)
|
||||||
|
if webhook_secret:
|
||||||
|
verify_signature(body_bytes, webhook_secret, signature_header)
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def handle_request(body: Dict[str, Any]):
|
async def handle_request(body: Dict[str, Any]):
|
||||||
"""
|
"""
|
||||||
Handle incoming GitHub webhook requests.
|
Handle incoming GitHub webhook requests.
|
||||||
|
Reference in New Issue
Block a user