Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/das/src/webhook/handlers/issue.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ export class IssueHandler {

await this.issueRepo.upsert(data, ["repoFullName", "issueNumber"]);

await this.repoRepo.update(repoFullName, {
const repoUpdate: Partial<Repo> = {
lastEventAt: new Date().toISOString(),
});
};
const defaultBranch: string | null =
payload.repository?.default_branch ?? null;
if (defaultBranch) {
repoUpdate.defaultBranch = defaultBranch;
}
await this.repoRepo.update(repoFullName, repoUpdate);
}
}
10 changes: 8 additions & 2 deletions packages/das/src/webhook/handlers/pull-request.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ export class PullRequestHandler {

await this.prRepo.upsert(data, ["repoFullName", "prNumber"]);

await this.repoRepo.update(repoFullName, {
const repoUpdate: Partial<Repo> = {
lastEventAt: new Date().toISOString(),
});
};
const defaultBranch: string | null =
payload.repository?.default_branch ?? null;
if (defaultBranch) {
repoUpdate.defaultBranch = defaultBranch;
}
await this.repoRepo.update(repoFullName, repoUpdate);

// Enqueue metadata fetch (closing issues + body + lastEditedAt) on relevant actions.
// Also run on `edited` so post-merge body edits are captured.
Expand Down
21 changes: 21 additions & 0 deletions packages/das/src/webhook/webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export class WebhookService {
}

switch (event) {
case "repository":
await this.handleRepositoryEvent(payload);
break;
case "pull_request":
await this.pullRequestHandler.handle(payload);
if (payload.action === "labeled" || payload.action === "unlabeled") {
Expand Down Expand Up @@ -119,4 +122,22 @@ export class WebhookService {
this.logger.debug(`Unhandled event type: ${event}`);
}
}

private async handleRepositoryEvent(
payload: Record<string, any>,
): Promise<void> {
const repoFullName: string | undefined = payload.repository?.full_name;
if (!repoFullName) return;

const repoUpdate: Partial<Repo> = {
lastEventAt: new Date().toISOString(),
};
const defaultBranch: string | null =
payload.repository?.default_branch ?? null;
if (defaultBranch) {
repoUpdate.defaultBranch = defaultBranch;
}

await this.repoRepo.update(repoFullName, repoUpdate);
}
}