feat: add GITEA webhook handler
This commit is contained in:
parent
5689425232
commit
4104153689
|
|
@ -168,6 +168,23 @@ def normalize_payload(integration_type: IntegrationType, payload: dict) -> Optio
|
|||
"labels": data.get("labels", [])
|
||||
}
|
||||
|
||||
elif integration_type == IntegrationType.GITEA:
|
||||
action = payload.get("action")
|
||||
if action != "opened":
|
||||
return None
|
||||
issue = payload.get("issue", {})
|
||||
repo = payload.get("repository", {})
|
||||
return {
|
||||
"external_id": str(issue.get("id")),
|
||||
"external_key": f"GITEA-{issue.get('number')}",
|
||||
"external_url": issue.get("html_url"),
|
||||
"title": issue.get("title"),
|
||||
"description": issue.get("body"),
|
||||
"priority": "medium",
|
||||
"labels": [l.get("name") for l in issue.get("labels", [])],
|
||||
"repo": repo.get("full_name")
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
def normalize_priority(priority: Optional[str]) -> str:
|
||||
|
|
@ -248,6 +265,16 @@ async def webhook_tickethub(
|
|||
payload = await request.json()
|
||||
return await process_webhook(org_id, IntegrationType.TICKETHUB, payload, background_tasks, db)
|
||||
|
||||
@router.post("/{org_id}/gitea")
|
||||
async def webhook_gitea(
|
||||
org_id: int,
|
||||
request: Request,
|
||||
background_tasks: BackgroundTasks,
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
payload = await request.json()
|
||||
return await process_webhook(org_id, IntegrationType.GITEA, payload, background_tasks, db)
|
||||
|
||||
@router.post("/{org_id}/generic")
|
||||
async def webhook_generic(
|
||||
org_id: int,
|
||||
|
|
|
|||
Loading…
Reference in New Issue