mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
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:
parent
e59b10f739
commit
a5324fb0ea
20 changed files with 425 additions and 136 deletions
|
|
@ -1,6 +1,14 @@
|
|||
import type { NeutralMessage, NeutralAuthor, NeutralAction } from "../types";
|
||||
import { GITHUB_COLORS } from "./colors";
|
||||
import { branchLink, emojiPrefix, type T, buildMessage, repoBaseUrl } from "./helpers";
|
||||
import {
|
||||
branchLink,
|
||||
cap,
|
||||
emojiPrefix,
|
||||
MAX_FIELD_VALUE,
|
||||
type T,
|
||||
buildMessage,
|
||||
repoBaseUrl,
|
||||
} from "./helpers";
|
||||
|
||||
export function formatPullRequest(
|
||||
payload: Record<string, unknown>,
|
||||
|
|
@ -82,7 +90,7 @@ export function formatPullRequest(
|
|||
if (pr.labels && pr.labels.length > 0) {
|
||||
fields.push({
|
||||
name: t("fields.labels"),
|
||||
value: pr.labels.map((l) => l.name).join(", "),
|
||||
value: cap(pr.labels.map((l) => l.name).join(", "), MAX_FIELD_VALUE),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -91,8 +99,16 @@ export function formatPullRequest(
|
|||
const actionable = pr.state === "open" && !!repoOwner && !!repoName && pr.number != null;
|
||||
const actions: NeutralAction[] | undefined = actionable
|
||||
? [
|
||||
{ id: `ghpr|merge|${repoOwner}|${repoName}|${pr.number}`, label: "合并", style: "primary" },
|
||||
{ id: `ghpr|close|${repoOwner}|${repoName}|${pr.number}`, label: "关闭", style: "danger" },
|
||||
{
|
||||
id: `ghpr|merge|${repoOwner}|${repoName}|${pr.number}`,
|
||||
label: t("actions.merge"),
|
||||
style: "primary",
|
||||
},
|
||||
{
|
||||
id: `ghpr|close|${repoOwner}|${repoName}|${pr.number}`,
|
||||
label: t("actions.close"),
|
||||
style: "danger",
|
||||
},
|
||||
]
|
||||
: undefined;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue