Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanDalelR authored Jan 18, 2024
2 parents e24b403 + 9a6d818 commit f6b9b06
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/api/actions/github/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,41 @@ export async function POST(request: Request) {
});
}

// If the count is surpassed, we replace the text
if (count.github_app_uses > 500) {
textToWrite = `Your team has surpassed the free monthly usage. [Please click here](https://buy.stripe.com/28o0289KVaYV5wY004) to upgrade.`;

const comments = await octokit.request(
"GET /repos/{owner}/{repo}/issues/{issue_number}/comments?sort=created&direction=desc",
{
owner,
repo,
issue_number: number,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
}
);

// Find our bot's comment
let botComment = comments.data.find((comment) => {
return comment?.user?.login.includes(
"watermelon-copilot-for-code-review"
);
});

// Update the existing comment
await octokit.request(
"PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}",
{
owner,
repo,
comment_id: botComment.id,
body: textToWrite,
}
);
}

successPosthogTracking({
url: request.url,
email: user_email,
Expand Down

0 comments on commit f6b9b06

Please sign in to comment.