diff --git a/otterdog/webapp/webhook/__init__.py b/otterdog/webapp/webhook/__init__.py index 0db4f438..dbc40a42 100644 --- a/otterdog/webapp/webhook/__init__.py +++ b/otterdog/webapp/webhook/__init__.py @@ -88,12 +88,16 @@ async def on_issue_comment_received(data): if event.installation is None or event.organization is None: return success() + # currently we only handle comments to pull requests + if event.issue.pull_request is None: + return success() + otterdog_config = get_otterdog_config() if event.repository.name != otterdog_config.default_config_repo: return success() - if event.action in ["created", "edited"] and "/pull/" in event.issue.html_url: + if event.action in ["created", "edited"]: org_id = event.organization.login installation_id = event.installation.id diff --git a/otterdog/webapp/webhook/github_models.py b/otterdog/webapp/webhook/github_models.py index e00cea74..16dd8de0 100644 --- a/otterdog/webapp/webhook/github_models.py +++ b/otterdog/webapp/webhook/github_models.py @@ -93,6 +93,13 @@ class Comment(BaseModel): updated_at: str +class AssociatedPullRequest(BaseModel): + """Indicates the associated pull request for an issue comment.""" + + url: str + html_url: str + + class Issue(BaseModel): """Represents an issue""" @@ -100,8 +107,9 @@ class Issue(BaseModel): node_id: str title: str state: str - draft: bool - body: Optional[str] + draft: Optional[bool] = None + body: Optional[str] = None + pull_request: Optional[AssociatedPullRequest] = None html_url: str