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:
RhenCloud 2026-08-14 08:49:48 +08:00
parent 17d10db845
commit 3f6f7f17b5
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
19 changed files with 469 additions and 108 deletions

View file

@ -14,7 +14,16 @@ groups:
# providers: ["github", "gitea"] # restrict to source platforms (optional; empty = all)
# installationId: 12345678 # GitHub App installation binding (auto-created on installation.created)
# emoji: true # include emoji in messages (default true)
# forgeLabel: false # show the forge source (GitHub / Gitea / custom) in message footers (default false)
# Forge hosts: label message footers with the host an event came from
# (optional `name` overrides the host as the display label).
# forgeSources:
# - host: "github.com" # GitHub events match github.com
# type: github
# name: "GitHub 主站" # optional display label
# - host: "git1.example.com" # a self-hosted Gitea instance
# type: gitea
# - host: "git2.example.com" # another one
# type: gitea
# lang: "en" # message language for this group's routes (en/zh, default en)
# Webhook log channel: a Discord channel/thread or Telegram chat/topic that
# receives a summary of every webhook this group's routes dispatch.