chore: auto-fix lint & formatting [skip ci]

This commit is contained in:
github-actions[bot] 2026-08-14 00:10:56 +00:00
parent 3dce114cec
commit 17d10db845
11 changed files with 50 additions and 56 deletions

View file

@ -46,27 +46,27 @@
/> />
<div class="hint">{{ t("groupEditor.langHint") }}</div> <div class="hint">{{ t("groupEditor.langHint") }}</div>
</div> </div>
<div class="field"> <div class="field">
<label <label
>{{ t("groupEditor.emoji") }} >{{ t("groupEditor.emoji") }}
<span class="lbl-note">{{ t("groupEditor.emojiNote") }}</span></label <span class="lbl-note">{{ t("groupEditor.emojiNote") }}</span></label
> >
<label class="inline"> <label class="inline">
<input v-model="form.emoji" type="checkbox" /> <input v-model="form.emoji" type="checkbox" />
<span>{{ t("groupEditor.emojiLabel") }}</span> <span>{{ t("groupEditor.emojiLabel") }}</span>
</label> </label>
</div> </div>
<div class="field"> <div class="field">
<label <label
>{{ t("groupEditor.forgeLabel") }} >{{ t("groupEditor.forgeLabel") }}
<span class="lbl-note">{{ t("groupEditor.forgeLabelNote") }}</span></label <span class="lbl-note">{{ t("groupEditor.forgeLabelNote") }}</span></label
> >
<label class="inline"> <label class="inline">
<input v-model="form.forgeLabel" type="checkbox" /> <input v-model="form.forgeLabel" type="checkbox" />
<span>{{ t("groupEditor.forgeLabelLabel") }}</span> <span>{{ t("groupEditor.forgeLabelLabel") }}</span>
</label> </label>
<div class="hint">{{ t("groupEditor.forgeLabelHint") }}</div> <div class="hint">{{ t("groupEditor.forgeLabelHint") }}</div>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label <label

View file

@ -456,7 +456,8 @@ const zh: Dict = {
"groupEditor.forgeLabel": "显示来源平台", "groupEditor.forgeLabel": "显示来源平台",
"groupEditor.forgeLabelNote": "(可选)", "groupEditor.forgeLabelNote": "(可选)",
"groupEditor.forgeLabelLabel": "在消息中标识事件来源GitHub / Gitea / 自定义)", "groupEditor.forgeLabelLabel": "在消息中标识事件来源GitHub / Gitea / 自定义)",
"groupEditor.forgeLabelHint": "在消息底部显示来源平台的图标与站点名称,便于区分不同 forge 的事件。", "groupEditor.forgeLabelHint":
"在消息底部显示来源平台的图标与站点名称,便于区分不同 forge 的事件。",
"groupEditor.logTarget": "Webhook 日志频道", "groupEditor.logTarget": "Webhook 日志频道",
"groupEditor.logTargetNote": "(可选)", "groupEditor.logTargetNote": "(可选)",
"groupEditor.logDisabled": "— 未启用 —", "groupEditor.logDisabled": "— 未启用 —",

View file

@ -30,7 +30,7 @@ Routes belong to groups. Groups scope admin access and can restrict which events
| `providers` | string[] | No | Source platforms allowed into this group (`github`, `gitea`); empty = all | | `providers` | string[] | No | Source platforms allowed into this group (`github`, `gitea`); empty = all |
| `installationId` | number | No | GitHub App installation id bound to this group; only that installation's events are accepted (empty = all) | | `installationId` | number | No | GitHub App installation id bound to this group; only that installation's events are accepted (empty = all) |
| `emoji` | boolean | No | Whether to include emoji in this group's messages (default `true`) | | `emoji` | boolean | No | Whether to include emoji in this group's messages (default `true`) |
| `forgeLabel` | boolean | No | Whether to show the forge source (GitHub / Gitea instance / custom) in the footer of this group's messages (default `false`) | | `forgeLabel` | boolean | No | Whether to show the forge source (GitHub / Gitea instance / custom) in the footer of this group's messages (default `false`) |
| `lang` | string | No | Message language for every route in this group (e.g. `en`, `zh`; custom via KV `i18n:<lang>`) — see [Message Language](./i18n) — defaults to `en` | | `lang` | string | No | Message language for every route in this group (e.g. `en`, `zh`; custom via KV `i18n:<lang>`) — see [Message Language](./i18n) — defaults to `en` |
| `logTarget` | object | No | Webhook log channel: a Discord `{ platform, channelId, threadId? }` or Telegram `{ platform, chatId, topicId? }` target that receives a summary of every webhook the group's routes dispatch | | `logTarget` | object | No | Webhook log channel: a Discord `{ platform, channelId, threadId? }` or Telegram `{ platform, chatId, topicId? }` target that receives a summary of every webhook the group's routes dispatch |

View file

@ -30,7 +30,7 @@
| `providers` | string[] | 否 | 允许进入该分组的来源平台(`github``gitea`);空 = 全部 | | `providers` | string[] | 否 | 允许进入该分组的来源平台(`github``gitea`);空 = 全部 |
| `installationId` | number | 否 | 绑定到该分组的 GitHub App 安装 id仅接受该安装的事件空 = 全部) | | `installationId` | number | 否 | 绑定到该分组的 GitHub App 安装 id仅接受该安装的事件空 = 全部) |
| `emoji` | boolean | 否 | 该分组消息是否包含表情(默认 `true` | | `emoji` | boolean | 否 | 该分组消息是否包含表情(默认 `true` |
| `forgeLabel` | boolean | 否 | 是否在该分组消息的底部显示来源平台标识GitHub / Gitea 实例 / 自定义)(默认 `false` | | `forgeLabel` | boolean | 否 | 是否在该分组消息的底部显示来源平台标识GitHub / Gitea 实例 / 自定义)(默认 `false` |
| `lang` | string | 否 | 该分组所有路由的消息语言(如 `en``zh`;可通过 KV `i18n:<lang>` 自定义)——见[消息语言](./i18n)——默认 `en` | | `lang` | string | 否 | 该分组所有路由的消息语言(如 `en``zh`;可通过 KV `i18n:<lang>` 自定义)——见[消息语言](./i18n)——默认 `en` |
| `logTarget` | object | 否 | Webhook 日志频道Discord 目标 `{ platform, channelId, threadId? }` 或 Telegram 目标 `{ platform, chatId, topicId? }`,接收该分组路由每次分发 webhook 的摘要 | | `logTarget` | object | 否 | Webhook 日志频道Discord 目标 `{ platform, channelId, threadId? }` 或 Telegram 目标 `{ platform, chatId, topicId? }`,接收该分组路由每次分发 webhook 的摘要 |

View file

@ -96,12 +96,7 @@ export async function dispatchEvent(
.map((a) => .map((a) =>
a.ok a.ok
? emojiPrefix("✅", true) + ? emojiPrefix("✅", true) +
translate( translate("log.route_ok", { route: a.routeName, target: a.target }, undefined, tr)
"log.route_ok",
{ route: a.routeName, target: a.target },
undefined,
tr,
)
: emojiPrefix("❌", true) + : emojiPrefix("❌", true) +
translate( translate(
"log.route_fail", "log.route_fail",

View file

@ -58,16 +58,12 @@ export function renderNeutralMessage(message: NeutralMessage): FormattedMessage
url: message.author.url, url: message.author.url,
} }
: undefined, : undefined,
fields: message.fields fields: message.fields?.slice(0, MAX_FIELDS).map((f) => ({
?.slice(0, MAX_FIELDS) name: cap(f.name, MAX_TITLE),
.map((f) => ({ value: cap(f.value, MAX_FIELD_VALUE),
name: cap(f.name, MAX_TITLE), inline: f.inline,
value: cap(f.value, MAX_FIELD_VALUE), })),
inline: f.inline, footer: footerText ? { text: footerText, icon_url: message.forge?.iconUrl } : undefined,
})),
footer: footerText
? { text: footerText, icon_url: message.forge?.iconUrl }
: undefined,
timestamp: message.timestamp, timestamp: message.timestamp,
}, },
], ],

View file

@ -170,7 +170,11 @@ export function forgeInfo(event: WebhookEvent): NeutralForge | undefined {
const repoUrl = (event.payload.repository as { html_url?: string } | undefined)?.html_url; const repoUrl = (event.payload.repository as { html_url?: string } | undefined)?.html_url;
switch (event.provider) { switch (event.provider) {
case "github": case "github":
return { name: "GitHub", url: "https://github.com", iconUrl: "https://github.com/favicon.ico" }; return {
name: "GitHub",
url: "https://github.com",
iconUrl: "https://github.com/favicon.ico",
};
case "gitea": { case "gitea": {
if (!repoUrl) return undefined; if (!repoUrl) return undefined;
try { try {

View file

@ -64,8 +64,7 @@ export function formatPush(
} }
if (created) { if (created) {
descriptionParts.push( descriptionParts.push(
em("🆕") + em("🆕") + t(isTagPush ? "events.push.tag_created" : "events.push.branch_created"),
t(isTagPush ? "events.push.tag_created" : "events.push.branch_created"),
); );
} }
@ -77,8 +76,8 @@ export function formatPush(
const commitField = (c: (typeof commits)[number]): { name: string; value: string } => { const commitField = (c: (typeof commits)[number]): { name: string; value: string } => {
const shortId = c.id?.slice(0, 7) ?? "???????"; const shortId = c.id?.slice(0, 7) ?? "???????";
const msg = (c.message?.split("\n")[0] ?? "").slice(0, MAX_COMMIT_SUBJECT) || const msg =
t("common.no_message"); (c.message?.split("\n")[0] ?? "").slice(0, MAX_COMMIT_SUBJECT) || t("common.no_message");
const url = baseUrl && c.id ? `${baseUrl}/commit/${c.id}` : null; const url = baseUrl && c.id ? `${baseUrl}/commit/${c.id}` : null;
const hash = url ? `[\`${shortId}\`](${url})` : `\`${shortId}\``; const hash = url ? `[\`${shortId}\`](${url})` : `\`${shortId}\``;
return { name: `\u200b`, value: `${hash} ${msg}` }; return { name: `\u200b`, value: `${hash} ${msg}` };

View file

@ -133,7 +133,8 @@ export function formatWorkflowRun(
if (workflow.jobs?.length) { if (workflow.jobs?.length) {
// Many-jobs workflows must stay under the Discord field value limit. // Many-jobs workflows must stay under the Discord field value limit.
const jobLines = workflow.jobs.map( const jobLines = workflow.jobs.map(
(j) => `${em(WORKFLOW_CONCLUSION_EMOJI[j.conclusion ?? ""] ?? "⏳")}${cap(j.name ?? "", 200)}`, (j) =>
`${em(WORKFLOW_CONCLUSION_EMOJI[j.conclusion ?? ""] ?? "⏳")}${cap(j.name ?? "", 200)}`,
); );
fields.push({ fields.push({
name: t("fields.job"), name: t("fields.job"),

View file

@ -521,9 +521,7 @@ describe("limits and localization", () => {
describe("forge source branding", () => { describe("forge source branding", () => {
it("github events brand as GitHub with the favicon", () => { it("github events brand as GitHub with the favicon", () => {
expect( expect(forgeInfo({ event: "push", provider: "github", payload: {} })).toEqual({
forgeInfo({ event: "push", provider: "github", payload: {} }),
).toEqual({
name: "GitHub", name: "GitHub",
url: "https://github.com", url: "https://github.com",
iconUrl: "https://github.com/favicon.ico", iconUrl: "https://github.com/favicon.ico",
@ -542,9 +540,7 @@ describe("forge source branding", () => {
url: "https://git.example.com", url: "https://git.example.com",
iconUrl: "https://git.example.com/favicon.ico", iconUrl: "https://git.example.com/favicon.ico",
}); });
expect( expect(forgeInfo({ event: "push", provider: "gitea", payload: {} })).toBeUndefined();
forgeInfo({ event: "push", provider: "gitea", payload: {} }),
).toBeUndefined();
}); });
it("custom events brand as a plain label without links", () => { it("custom events brand as a plain label without links", () => {

View file

@ -35,11 +35,13 @@ describe("telegram renderNeutralMessage", () => {
const out = renderNeutralMessage({ const out = renderNeutralMessage({
title: "acme/widget: Add feature", title: "acme/widget: Add feature",
footer: "acme/widget", footer: "acme/widget",
forge: { name: "GitHub", url: "https://github.com", iconUrl: "https://github.com/favicon.ico" }, forge: {
name: "GitHub",
url: "https://github.com",
iconUrl: "https://github.com/favicon.ico",
},
}); });
expect(out).toContain( expect(out).toContain('<i><a href="https://github.com">GitHub</a> · acme/widget</i>');
'<i><a href="https://github.com">GitHub</a> · acme/widget</i>',
);
const gitea = renderNeutralMessage({ const gitea = renderNeutralMessage({
title: "org/repo: Add feature", title: "org/repo: Add feature",