From 3dce114cec3cc30e1eeea22094ac4213f6583ef4 Mon Sep 17 00:00:00 2001 From: RhenCloud Date: Fri, 14 Aug 2026 08:10:04 +0800 Subject: [PATCH] feat(groups): optional forge source label in message footers - Group.forgeLabel (default off, editable per group in the console) shows the source forge on every message the group's routes dispatch - Discord embed footer: forge name next to the repo + the site's favicon as icon_url (Gitea instance's own favicon from its origin) - Telegram footer: hyperlinked site name (GitHub or Gitea hostname); custom webhooks render a plain 'Custom' label - forgeInfo() derives branding from event.provider + repository.html_url; dispatch attaches it to the NeutralMessage like mentionRoleIds - validateGroups accepts forgeLabel booleans; GroupEditor gains the toggle - tests: forgeInfo unit, discord/telegram footer render, dispatch on/off - docs: groups.md + message-format.md (en/zh), config.example.yaml, AGENTS.md - fix: wrangler.jsonc compatibility_date was an incomplete '2026-' --- AGENTS.md | 2 + app/components/GroupEditor.vue | 34 +++++++---- app/composables/useI18n.ts | 9 +++ app/types.ts | 1 + config.example.yaml | 1 + docs/guide/groups.md | 11 ++++ docs/guide/message-format.md | 4 ++ docs/zh/guide/groups.md | 11 ++++ docs/zh/guide/message-format.md | 4 ++ server/lib/core/dispatch.ts | 5 +- server/lib/drivers/discord/render.ts | 8 ++- server/lib/drivers/telegram/render.ts | 4 ++ server/lib/formatters/helpers.ts | 28 ++++++++- server/lib/types.ts | 26 ++++++++- server/lib/web/admin.ts | 3 + tests/discord.test.ts | 82 +++++++++++++++++++++++++++ tests/formatter.test.ts | 37 +++++++++++- tests/telegram.test.ts | 17 ++++++ wrangler.jsonc | 2 +- 19 files changed, 273 insertions(+), 16 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index bb4993f..f133059 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,6 +23,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord - Invites: single-use 7-day links (`invite:{token}`) for joining a group as admin/viewer; `ALLOW_SELF_SIGNUP=1` gives access-less users a personal group on first login (self-service SaaS entry) - Audit log: every admin operation (logins, group/route/member/invite changes) recorded in D1 `audit_logs`; pruned by the scheduled trigger after `AUDIT_RETENTION_DAYS` (default 90) - Group webhook log channel: optional `Group.logTarget` (Discord channel/thread or Telegram chat/topic) receives one summary message per webhook the group's routes dispatched (event, repo, delivery id, per route×target ✅/❌ outcome, green/red color); best-effort, not recorded in `send_logs` +- Per-group forge branding: optional `Group.forgeLabel` (default off) renders the source forge in the message footer — GitHub brand + favicon, Gitea instance hostname + favicon (from the repo URL origin), or plain `Custom` for custom webhooks; Discord shows the footer icon + name, Telegram a linked name - Local dev: wrangler + Miniflare ## Architecture @@ -124,6 +125,7 @@ tests/ # bun test unit tests (webhook, formatter, discord, tel - Record every admin operation (login/logout, group/route/member/invite changes) to D1 `audit_logs`; the scheduled trigger prunes entries past `AUDIT_RETENTION_DAYS` - Mention Discord roles on route trigger: route-level `discordRoleIds` are rendered as `<@&id>` into the Discord message `content` (Telegram targets ignore the field) - Format 28 GitHub/Gitea event types plus `custom` webhooks as platform-neutral messages (Discord embeds + Telegram HTML) +- Show the forge source (GitHub / Gitea instance / custom) in the message footer when the group enables `Group.forgeLabel` - Route messages to Discord channels/threads and Telegram chats/topics via REST - Edit already-sent messages in place for `workflow_run` / `check_run` progress (stable `updateKey`, KV `msg:*` tracking) - Record every dispatch attempt to D1 `send_logs` (route id, event, target, ok/error, duration, error code) diff --git a/app/components/GroupEditor.vue b/app/components/GroupEditor.vue index bc9366d..765d497 100644 --- a/app/components/GroupEditor.vue +++ b/app/components/GroupEditor.vue @@ -46,16 +46,27 @@ />
{{ t("groupEditor.langHint") }}
-
- - -
+
+ + +
+
+ + +
{{ t("groupEditor.forgeLabelHint") }}
+