Handle Gitea review webhook type field alongside state
Publish Image / publish (push) Successful in 23s
Publish Image / publish (push) Successful in 23s
Gitea webhook payloads use "type" (e.g. "pull_request_review_rejected") instead of "state" (e.g. "REQUEST_CHANGES"). Map both formats so the pr-rework handler works with all Gitea webhook variations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
a72ea9ad1d
commit
f693d56762
@@ -16,14 +16,33 @@ export function prRework(config: Config, queue: TaskQueue) {
|
||||
return c.text("ignored: not a reviewed event", 200);
|
||||
}
|
||||
|
||||
if (!event.review?.state) {
|
||||
console.log(`[pr-rework] ignored: no review state (review: ${JSON.stringify(event.review)})`);
|
||||
if (!event.review) {
|
||||
console.log(`[pr-rework] ignored: no review object`);
|
||||
return c.text("ignored: no review data", 200);
|
||||
}
|
||||
|
||||
const [org, repo] = event.repository.full_name.split("/");
|
||||
const prNumber = event.pull_request.number;
|
||||
const reviewState = event.review.state.toLowerCase();
|
||||
|
||||
// Gitea webhook payloads use "state" in the API but "type" in webhooks
|
||||
// state: "REQUEST_CHANGES" | "APPROVED" | "COMMENT"
|
||||
// type: "pull_request_review_rejected" | "pull_request_review_approved" | ...
|
||||
let reviewState: string;
|
||||
if (event.review.state) {
|
||||
reviewState = event.review.state.toLowerCase();
|
||||
} else if (event.review.type) {
|
||||
const typeMap: Record<string, string> = {
|
||||
pull_request_review_rejected: "request_changes",
|
||||
pull_request_review_approved: "approved",
|
||||
pull_request_review_comment: "comment",
|
||||
};
|
||||
reviewState = typeMap[event.review.type] || event.review.type;
|
||||
} else {
|
||||
console.log(`[pr-rework] ignored: no review state or type (review: ${JSON.stringify(event.review)})`);
|
||||
return c.text("ignored: no review state", 200);
|
||||
}
|
||||
|
||||
console.log(`[pr-rework] PR #${prNumber} review: ${reviewState}`);
|
||||
|
||||
let taskType: string | null = null;
|
||||
let giteaToken: string;
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ export interface GiteaPullRequest {
|
||||
export interface GiteaReview {
|
||||
id: number;
|
||||
body: string;
|
||||
state: string; // "approved", "request_changes", "comment"
|
||||
state?: string; // "approved", "request_changes", "comment" (API response)
|
||||
type?: string; // "pull_request_review_rejected" | "pull_request_review_approved" (webhook payload)
|
||||
user: GiteaUser;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user