chore: update src/pages/api/repos/[owner]/[repo]/pulls/[number]/reviews.ts
swadhinbiswas committed 8 months ago
7f9a0c7
1 parent 63258a0
commit 7f9a0c7
1 file changed
+3 -4
Showing 1 changed file+3-4
▼src/pages/api/repos/[owner]/[repo]/pulls/[number]/reviews.ts
+3-4
| @@ -46,10 +46,9 @@ export const POST: APIRoute = withErrorHandler(async ({ params, request, locals | ||
46 | 46 | return notFound("Repository not found"); |
47 | 47 | } |
48 | 48 | |
49 | - // Only write access can approve/request changes? | |
50 | - // Usually anyone with read access can comment, but approvals might require write access depending on rules. | |
51 | - // For now, let's allow anyone with read access to review, but maybe distinguish later. | |
52 | - // GitHub allows read-access users to review. | |
49 | + if (state !== "COMMENTED" && !(await canWriteRepo(user.id, repo))) { | |
50 | + return forbidden("Write access required to approve or request changes"); | |
51 | + } | |
53 | 52 | |
54 | 53 | const pr = await db.query.pullRequests.findFirst({ |
55 | 54 | where: and( |
56 | 55 | |