From baa01aa0e3fa61ea966a2f3003237992a0a97574 Mon Sep 17 00:00:00 2001 From: afuhflynn Date: Mon, 29 Dec 2025 04:29:00 +0100 Subject: [PATCH] feat: add some new changes --- app/api/webhooks/github/route.ts | 1 - lib/ai/actions/index.ts | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/api/webhooks/github/route.ts b/app/api/webhooks/github/route.ts index 1dc79ec..1119560 100644 --- a/app/api/webhooks/github/route.ts +++ b/app/api/webhooks/github/route.ts @@ -110,7 +110,6 @@ export async function POST(request: NextRequest) { owner, repoName, prNumber, - body?.installation?.id, pull_request?.base?.sha, pull_request?.head?.sha ) diff --git a/lib/ai/actions/index.ts b/lib/ai/actions/index.ts index 4fb0400..78fb0b7 100644 --- a/lib/ai/actions/index.ts +++ b/lib/ai/actions/index.ts @@ -8,7 +8,6 @@ export async function reviewPullRequest( owner: string, repo: string, prNumber: number, - installationId: number, baseSha: string, headSha: string ) { @@ -87,6 +86,27 @@ export async function reviewPullRequest( }, }); + const account = await prisma.account.findFirst({ + where: { + accountId: String(githubAccount.accountId), + }, + include: { + user: true, + }, + }); + + if (!account) { + throw new Error("Invalid account"); + } + const installation = await prisma.installation.findFirst({ + where: { + userId: account.user.id, + }, + select: { + installationId: true, + }, + }); + await inngest.send({ name: "pr.summary.requested", data: { @@ -96,7 +116,7 @@ export async function reviewPullRequest( title: title ?? "", description: description ?? "", accountId: githubAccount.accountId, - installationId: installationId ?? null, + installationId: installation?.installationId ?? null, baseSha, headSha, changedFiles: changed_files ?? 0,