feat(formatters): add updateKey for suite/deployment/comment edit-in-place

This commit is contained in:
RhenCloud 2026-08-15 18:18:52 +08:00
parent 3af50496a7
commit 2f8a87048e
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
4 changed files with 12 additions and 0 deletions

View file

@ -21,6 +21,7 @@ export function formatCheckSuite(
showEmoji: boolean,
): NeutralMessage {
const suite = payload.check_suite as {
id?: number;
head_branch?: string;
head_sha?: string;
conclusion?: string;
@ -78,6 +79,7 @@ export function formatCheckSuite(
suite.html_url ??
(baseUrl && suite.head_sha ? `${baseUrl}/commit/${suite.head_sha}/checks` : undefined),
color: GITHUB_COLORS[colorKey],
updateKey: repo && suite.id != null ? `check_suite:${repo}:${suite.id}` : undefined,
fields,
},
t,

View file

@ -16,6 +16,7 @@ export function formatIssueComment(
html_url?: string;
};
const comment = payload.comment as {
id?: number;
body?: string;
html_url?: string;
};
@ -35,6 +36,7 @@ export function formatIssueComment(
}),
url: comment.html_url ?? issue.html_url,
color: GITHUB_COLORS.issue_comment,
updateKey: repo && comment.id != null ? `issue_comment:${repo}:${comment.id}` : undefined,
description: `${t("events.issue_comment.action_comment", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`,
},
t,

View file

@ -42,6 +42,7 @@ export function formatDeployment(
showEmoji: boolean,
): NeutralMessage {
const deployment = payload.deployment as {
id?: number;
environment?: string;
ref?: string;
sha?: string;
@ -88,6 +89,7 @@ export function formatDeployment(
}),
url: deployment.html_url ?? deployment.statuses_url,
color: GITHUB_COLORS.deployment_pending,
updateKey: repo && deployment.id != null ? `deployment:${repo}:${deployment.id}` : undefined,
fields,
},
t,
@ -109,6 +111,7 @@ export function formatDeploymentStatus(
description?: string;
};
const deployment = payload.deployment as {
id?: number;
sha?: string;
ref?: string;
environment?: string;
@ -163,6 +166,7 @@ export function formatDeploymentStatus(
author,
title: t("events.deployment.title", { repo: repo ?? t("common.repository"), env, state }),
color: GITHUB_COLORS[colorKey],
updateKey: repo && deployment.id != null ? `deployment:${repo}:${deployment.id}` : undefined,
fields,
},
t,

View file

@ -11,6 +11,7 @@ export function formatPullRequestReview(
): NeutralMessage {
const action = (payload.action as string) ?? "submitted";
const review = payload.review as {
id?: number;
state?: string;
body?: string;
html_url?: string;
@ -50,6 +51,7 @@ export function formatPullRequestReview(
}),
url: review.html_url,
color: GITHUB_COLORS[colorKey],
updateKey: repo && review.id != null ? `pull_request_review:${repo}:${review.id}` : undefined,
description: descriptionParts.join("\n"),
},
t,
@ -66,6 +68,7 @@ export function formatPullRequestReviewComment(
): NeutralMessage {
const action = (payload.action as string) ?? "created";
const comment = payload.comment as {
id?: number;
body?: string;
path?: string;
position?: number | null;
@ -105,6 +108,7 @@ export function formatPullRequestReviewComment(
}),
url: comment.html_url,
color: GITHUB_COLORS.pull_request_review_commented,
updateKey: repo && comment.id != null ? `pull_request_review_comment:${repo}:${comment.id}` : undefined,
description: `${t("events.pr_review_comment.action_inline", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`,
fields: fields.length > 0 ? fields : undefined,
},