mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat(groups): host-based forge sources with optional display name
- forgeSources entries are now { host, type, name? }: the repository URL's
hostname is matched case-insensitively against host (github.com for GitHub,
distinct hosts for multiple Gitea instances); the footer label is the
optional name, falling back to the host
- GroupEditor renders one row per source: host input + type select + optional
display name (grid layout); hostname validation mirrors the server
- fix: apiFetch sends Content-Type: application/json — h3's readBody only
parses JSON bodies with that header, so every PUT/POST from the refactored
console arrived as a raw string and failed with 'groups must be an array'
- hardening: readJsonBody (admin + actions) JSON-parses string bodies so curl
and older clients without the content-type header still work
- regression test: groups PUT without content-type + forgeSources round-trip
- docs: groups.md/message-format.md (en/zh), AGENTS.md, config.example.yaml
This commit is contained in:
parent
17d10db845
commit
3f6f7f17b5
19 changed files with 469 additions and 108 deletions
|
|
@ -385,7 +385,7 @@ describe("dispatchEvent fallback routing", () => {
|
|||
expect(logBody.embeds?.[0]?.fields?.[0]?.value).toContain("❌ Push Route → 111");
|
||||
});
|
||||
|
||||
it("attaches the forge label when the group enables it", async () => {
|
||||
it("attaches the forge label when the group defines a matching host", async () => {
|
||||
const bodies: string[] = [];
|
||||
mockFetch((url, init) => {
|
||||
bodies.push(String(init?.body ?? ""));
|
||||
|
|
@ -395,7 +395,12 @@ describe("dispatchEvent fallback routing", () => {
|
|||
await kv.put(
|
||||
"config:groups",
|
||||
JSON.stringify([
|
||||
{ id: "gh", name: "GH", adminIds: [], forgeLabel: true },
|
||||
{
|
||||
id: "gh",
|
||||
name: "GH",
|
||||
adminIds: [],
|
||||
forgeSources: [{ host: "git.example.com", type: "gitea", name: "内网 Gitea" }],
|
||||
},
|
||||
{ id: "plain", name: "Plain", adminIds: [] },
|
||||
]),
|
||||
);
|
||||
|
|
@ -445,7 +450,7 @@ describe("dispatchEvent fallback routing", () => {
|
|||
return parsed.embeds?.[0]?.footer;
|
||||
});
|
||||
expect(footers).toContainEqual({
|
||||
text: "git.example.com · owner/repo",
|
||||
text: "内网 Gitea · owner/repo",
|
||||
icon_url: "https://git.example.com/favicon.ico",
|
||||
});
|
||||
expect(footers).toContainEqual({ text: "owner/repo" });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue