fix(formatters): localize PR buttons, cap oversized content, dedupe status logic

- PR merge/close button labels now follow the group language (actions.merge/close)
  instead of hardcoded Chinese
- clamp content to Discord embed limits (title 256, description 4096, field value
  1024, 25 fields) in formatters plus a render-layer safety net; Telegram gets a
  tag-safe 4096-char cap (capHtml closes dangling tags)
- raise commit subject truncation from 72 to 200 chars (MAX_COMMIT_SUBJECT)
- extract workflowStatus/workflowRunStatus/statusColorKey helpers shared by
  check_run/check_suite/workflow_run/workflow_job
- dedupe deployment ref/sha fields via addDeploymentRefFields
- commit_comment without a commit id uses title_plain (no dangling ???????)
- tag pushes now report 'Tag created'; zh push title includes the {ref}
- sender profile link derives from the repo's forge origin instead of github.com
- group webhook log emoji injected via emojiPrefix, removed from locale files
- dispatchEvent accepts preloaded groups (single KV read per webhook)
- webhook 401 logs distinguish 'secret not configured' from 'invalid signature'
This commit is contained in:
RhenCloud 2026-08-14 07:41:19 +08:00
parent e59b10f739
commit a5324fb0ea
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
20 changed files with 425 additions and 136 deletions

View file

@ -1,6 +1,17 @@
import type { NeutralMessage, NeutralAuthor } from "../types";
import { GITHUB_COLORS, WORKFLOW_CONCLUSION_EMOJI } from "./colors";
import { branchLink, commitLink, emojiPrefix, type T, buildMessage, repoBaseUrl } from "./helpers";
import {
branchLink,
cap,
commitLink,
emojiPrefix,
MAX_FIELD_VALUE,
statusColorKey,
type T,
buildMessage,
repoBaseUrl,
workflowStatus,
} from "./helpers";
export function formatCheckSuite(
payload: Record<string, unknown>,
@ -18,21 +29,11 @@ export function formatCheckSuite(
html_url?: string;
};
const status =
suite.status === "queued"
? "queued"
: suite.status === "in_progress"
? "running"
: (suite.conclusion ?? "pending");
const status = workflowStatus(suite.status, suite.conclusion);
const baseUrl = repoBaseUrl(payload, repo);
const emoji = WORKFLOW_CONCLUSION_EMOJI[status] ?? "⏳";
const em = (e: string): string => emojiPrefix(e, showEmoji);
const colorKey =
status === "success"
? "check_run_success"
: status === "failure"
? "check_run_failure"
: "check_run_other";
const colorKey = statusColorKey("check_run", status);
const fields: Array<{ name: string; value: string; inline?: boolean }> = [];
@ -172,20 +173,10 @@ export function formatCheckRun(
output?: { title?: string; summary?: string };
};
const status =
checkRun.status === "queued"
? "queued"
: checkRun.status === "in_progress"
? "running"
: (checkRun.conclusion ?? "pending");
const status = workflowStatus(checkRun.status, checkRun.conclusion);
const emoji = WORKFLOW_CONCLUSION_EMOJI[status] ?? "⏳";
const em = (e: string): string => emojiPrefix(e, showEmoji);
const colorKey =
status === "success"
? "check_run_success"
: status === "failure"
? "check_run_failure"
: "check_run_other";
const colorKey = statusColorKey("check_run", status);
const fields: Array<{ name: string; value: string; inline?: boolean }> = [];
@ -198,7 +189,7 @@ export function formatCheckRun(
if (checkRun.output?.title) {
fields.push({
name: t("fields.details"),
value: checkRun.output.title,
value: cap(checkRun.output.title, MAX_FIELD_VALUE),
inline: false,
});
}