diff --git a/.env.example b/.env.example index 71852f2..3dfb0f1 100644 --- a/.env.example +++ b/.env.example @@ -33,5 +33,5 @@ BASE_URL=http://localhost:8787 # Optional (public runtime config, consumed by the Nuxt pages) # NUXT_PUBLIC_DOCS_URL=https://your-docs-site -# NUXT_PUBLIC_REPO_URL=https://github.com/ReCloudStudio/WebHooker +# NUXT_PUBLIC_REPO_URL=https://github.com/Elysola/WebHooker # NUXT_PUBLIC_LEGAL_CONTACT=contact@example.com diff --git a/AGENTS.md b/AGENTS.md index 674bb56..ca0609e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,8 +9,8 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord ## Key Decisions - Runtime: Cloudflare Workers via the Nitro `cloudflare_module` preset (`_worker.js`), H3 event handlers in `server/routes/` -- UI: Vue 3 + Tailwind CSS v4 (`@tailwindcss/vite`) + `@recloudstudio/ui` (Nuxt module, `Rc` prefix); admin console is a client-side SPA (`routeRules: "/admin/**": { ssr: false }`), home/legal pages render server-side -- Styling: ReCloud UI supplies semantic components and blue theme tokens; `app/assets/css/main.css` retains `--wh-*` RGB-triplet aliases for app-specific Tailwind utilities and bespoke layouts (avoiding collision with ReCloud's `--surface`/`--text`/`--border` hex tokens); theme switching supports auto/light/dark via `useTheme` / `ThemeToggle`, toggling `.dark` with inline anti-flash head script +- UI: Vue 3 + Tailwind CSS v4 (`@tailwindcss/vite`) + `@elysola/ui` (Nuxt module, `Rc` prefix); admin console is a client-side SPA (`routeRules: "/admin/**": { ssr: false }`), home/legal pages render server-side +- Styling: Elysola UI supplies semantic components and blue theme tokens; `app/assets/css/main.css` retains `--wh-*` RGB-triplet aliases for app-specific Tailwind utilities and bespoke layouts (avoiding collision with Elysola's `--surface`/`--text`/`--border` hex tokens); theme switching supports auto/light/dark via `useTheme` / `ThemeToggle`, toggling `.dark` with inline anti-flash head script - Discord interactions: HTTPS Interactions Endpoint (`POST /discord/interactions`, Ed25519-signed) — no Discord Gateway / Durable Object; bot stays offline, messages always sent via REST - Storage: D1 is the source of truth for config (routes/groups via `d1_routes`/`d1_groups`, see `server/lib/storage/config-store.ts`), send/audit logs, dedup (`dedup_keys`), delivery state (`delivery_state`) and message tracking (`message_tracking` via `server/lib/storage/d1.ts` `canUseD1` gate). KV keeps only cache + short-lived/ephemeral state (tokens, OAuth state, admin sessions, `msg:*`-adjacent locks, per-group secrets `tenant:*`, invites, i18n overrides) with explicit TTLs. R2 parks oversized queue payloads (`webhooks/YYYY/MM/DD/*.json`, `server/lib/storage/payload.ts`) instead of KV. A `storage-prune` scheduled task cleans up expired dedup/delivery/message-tracking rows - Signature verification: Web Crypto API (HMAC-SHA256 for GitHub/Gitea, Ed25519 for Discord, timing-safe secret-token compare for Telegram) @@ -34,7 +34,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord ```text app/ # Vue 3 UI (Nuxt app dir) ├── app.vue # root component (NuxtPage) -├── assets/css/main.css # Tailwind v4 entry: ReCloud-compatible RGB aliases + bespoke layout classes + Vue transition glue +├── assets/css/main.css # Tailwind v4 entry: Elysola-compatible RGB aliases + bespoke layout classes + Vue transition glue ├── pages/ # index (landing), terms, privacy, admin/[...slug] (console SPA) ├── components/ # ConsolePage (sidebar shell + topbar), AdminHome (overview dashboard), │ # RouteCard/Editor (RouteEditor has FilterNodeEditor AST builder + TagInput chips), diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f129035..8445776 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ Cloudflare Worker, receiving GitHub/Gitea webhooks and dispatching them to Disco [Bun](https://bun.sh) is the only supported package manager — never use `npm`/`npx`. ```bash -git clone https://github.com/ReCloudStudio/WebHooker.git +git clone https://github.com/Elysola/WebHooker.git cd WebHooker bun install cp .env.example .dev.vars # Fill in secrets for local dev (wrangler reads this) diff --git a/README.md b/README.md index d06abfc..19290be 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ GitHub / Gitea webhook → Discord / Telegram / Feishu dispatcher. Receives webh - `workflow_run` / `check_run` progress is edited **in place** (single message updated as the run advances) on Discord, Telegram, and Feishu — `check_run` tracks by check name + commit SHA so deployments that issue a fresh run id per phase (e.g. Cloudflare Pages) still edit the same message; `workflow_run` embeds a colored per-job code block (🟢 success, 🔴 failure, running/queued inline) - **Per-group webhook log channel** — point a group at a Discord channel/thread, Telegram chat/topic, or Feishu chat and every webhook the group's routes dispatch is summarized there (✅/❌ per route × target) - GitHub OAuth for user actions (comment, edit comment, delete comment, merge, close, react) -- **Web UI config console** (`/admin`) — ReCloud UI-based console with centered route/group dialogs; manage routes and groups with GitHub OAuth + admin whitelist, view send logs +- **Web UI config console** (`/admin`) — Elysola UI-based console with centered route/group dialogs; manage routes and groups with GitHub OAuth + admin whitelist, view send logs - **Discord Interactions Endpoint** (Ed25519-verified) for `/gh` slash commands, message context-menu commands, PR merge/close buttons, and comment modals - **Telegram `/gh` commands** (login/logout/comment/merge/close) via the Telegram webhook, with avatar link-preview cards - Cloudflare D1 for config (routes/groups), send logs, platform account links, dedup, delivery state and message tracking + KV for ephemeral state/cache/security tokens, + optional R2 for oversized payloads @@ -103,7 +103,7 @@ Routes are stored in D1 (`d1_routes`, seeded from legacy KV `config:routes` on f ] ``` -`target.platform` selects the push target: `discord` (default), `telegram`, or `feishu`. Discord targets require `target.channelId` (optional `threadId` for a thread); Telegram targets require `target.chatId` (optional `topicId` for a topic); Feishu targets require `target.chatId` (optional `topicId` for a topic). A route may also set `stop: true` (skip later routes). Routes belong to **groups** (D1 `d1_groups`, seeded from legacy KV `config:groups`) that scope admin access and can restrict which org/user events flow in. See the [Routes & Targets](https://webhooker.docs.worldexecute.me/guide/routes) and [Groups & Access Control](https://webhooker.docs.worldexecute.me/guide/groups) guides for the full schema. +`target.platform` selects the push target: `discord` (default), `telegram`, or `feishu`. Discord targets require `target.channelId` (optional `threadId` for a thread); Telegram targets require `target.chatId` (optional `topicId` for a topic); Feishu targets require `target.chatId` (optional `topicId` for a topic). A route may also set `stop: true` (skip later routes). Routes belong to **groups** (D1 `d1_groups`, seeded from legacy KV `config:groups`) that scope admin access and can restrict which org/user events flow in. See the [Routes & Targets](https://webhooker.docs.elysola.org/guide/routes) and [Groups & Access Control](https://webhooker.docs.elysola.org/guide/groups) guides for the full schema. ### Web UI (`/admin`) @@ -119,7 +119,7 @@ Sign out at `/admin/logout`. Every group has `members` with a role (`owner` / `a ### Filter Types -Every filter supports plain text, `*`/`?` globs, and `/regex/` patterns (case-insensitive); set `exclude: true` to invert. A `field` filter reads any payload value by JSONPath (arrays expand so any element matches) and accepts an `op` operator (default `eq`); `op: "exists"` checks presence without a `match`. Filters can also be grouped into an AST via an optional `ast` on a route (`all` / `any` / `not` nodes) to express boolean combinations beyond the default AND-list — when present, `ast` takes precedence over `filters`. The route editor provides a visual AST builder, chip multi-value input, a stateless match tester, and named filter fragments (stored in D1 `d1_fragments`). See the [Filter Tutorial](https://webhooker.docs.worldexecute.me/guide/filters) for the pattern syntax and the full filter reference. +Every filter supports plain text, `*`/`?` globs, and `/regex/` patterns (case-insensitive); set `exclude: true` to invert. A `field` filter reads any payload value by JSONPath (arrays expand so any element matches) and accepts an `op` operator (default `eq`); `op: "exists"` checks presence without a `match`. Filters can also be grouped into an AST via an optional `ast` on a route (`all` / `any` / `not` nodes) to express boolean combinations beyond the default AND-list — when present, `ast` takes precedence over `filters`. The route editor provides a visual AST builder, chip multi-value input, a stateless match tester, and named filter fragments (stored in D1 `d1_fragments`). See the [Filter Tutorial](https://webhooker.docs.elysola.org/guide/filters) for the pattern syntax and the full filter reference. ## API @@ -164,11 +164,11 @@ Every filter supports plain text, `*`/`?` globs, and `/regex/` patterns (case-in ## Setup Guides -- **GitHub App** — create the app, subscribe to events, configure OAuth, and set the _Setup URL_ for tenant isolation: see [GitHub App Setup](https://webhooker.docs.worldexecute.me/guide/deployment#github-app-setup) -- **Discord bot** — create the bot, invite it with `applications.commands` (combined permission integer `274877910016`), and configure the Interactions Endpoint: see [Discord Bot Setup](https://webhooker.docs.worldexecute.me/guide/deployment#discord-bot-setup). The bot never connects to the Discord Gateway, so it shows as **offline** — messaging is unaffected (always REST). -- **Telegram bot** — create the bot with [@BotFather](https://t.me/BotFather), set `TELEGRAM_TOKEN` (optional `TELEGRAM_WEBHOOK_SECRET`); the webhook is synced automatically by the scheduled trigger: see [Telegram Bot Setup](https://webhooker.docs.worldexecute.me/guide/deployment#telegram-bot-setup) -- **Feishu bot** — create a custom app, enable the bot, add it to the target group, and set `FEISHU_APP_ID` + `FEISHU_APP_SECRET`: see [Feishu Bot Setup](https://webhooker.docs.worldexecute.me/guide/deployment#feishu-bot-setup) -- **Deployment** — KV namespace, D1 database + migrations, optional Queues, secrets, and deploy: see the [Deployment guide](https://webhooker.docs.worldexecute.me/guide/deployment) +- **GitHub App** — create the app, subscribe to events, configure OAuth, and set the _Setup URL_ for tenant isolation: see [GitHub App Setup](https://webhooker.docs.elysola.org/guide/deployment#github-app-setup) +- **Discord bot** — create the bot, invite it with `applications.commands` (combined permission integer `274877910016`), and configure the Interactions Endpoint: see [Discord Bot Setup](https://webhooker.docs.elysola.org/guide/deployment#discord-bot-setup). The bot never connects to the Discord Gateway, so it shows as **offline** — messaging is unaffected (always REST). +- **Telegram bot** — create the bot with [@BotFather](https://t.me/BotFather), set `TELEGRAM_TOKEN` (optional `TELEGRAM_WEBHOOK_SECRET`); the webhook is synced automatically by the scheduled trigger: see [Telegram Bot Setup](https://webhooker.docs.elysola.org/guide/deployment#telegram-bot-setup) +- **Feishu bot** — create a custom app, enable the bot, add it to the target group, and set `FEISHU_APP_ID` + `FEISHU_APP_SECRET`: see [Feishu Bot Setup](https://webhooker.docs.elysola.org/guide/deployment#feishu-bot-setup) +- **Deployment** — KV namespace, D1 database + migrations, optional Queues, secrets, and deploy: see the [Deployment guide](https://webhooker.docs.elysola.org/guide/deployment) ### Bot Commands (comment on GitHub as yourself) @@ -179,7 +179,7 @@ The bot registers native **slash** and **message context-menu** commands, synced /gh comment add|edit|del link: (or right-click a notification → Apps → GitHub: 添加/编辑/删除评论) ``` -See the full reference in the [Bot Commands guide](https://webhooker.docs.worldexecute.me/guide/commands). +See the full reference in the [Bot Commands guide](https://webhooker.docs.elysola.org/guide/commands). ## Development @@ -192,7 +192,7 @@ bun test # Unit tests ## Supported Events -28 event formatters (push, pull_request, issues, workflow_run, release, ...) plus `custom` webhooks; unsupported events fall back to a generic formatter. See the full table with embed highlights in [Supported Events](https://webhooker.docs.worldexecute.me/events/supported). +28 event formatters (push, pull_request, issues, workflow_run, release, ...) plus `custom` webhooks; unsupported events fall back to a generic formatter. See the full table with embed highlights in [Supported Events](https://webhooker.docs.elysola.org/events/supported). ## License diff --git a/README.zh.md b/README.zh.md index 3b39a75..433f5ea 100644 --- a/README.zh.md +++ b/README.zh.md @@ -16,7 +16,7 @@ GitHub / Gitea webhook → Discord / Telegram / 飞书 分发服务。通过 Clo - `workflow_run` / `check_run` 进度**原地编辑**同一条消息(运行推进时更新),Discord、Telegram 与飞书均支持 —— `check_run` 以 check 名 + commit SHA 追踪,因此每个阶段都换新 run id 的部署(如 Cloudflare Pages)仍会编辑同一条消息;`workflow_run` 内嵌带颜色的逐作业代码块(🟢 成功、🔴 失败、运行中/排队中不着色) - **分组级 Webhook 日志频道** —— 为分组指定一个 Discord 频道/子区、Telegram 群组/话题或飞书群聊,该分组路由每次分发 webhook 都会向其中发送摘要(每条「路由 × 目标」一行,✅/❌ 结果) - GitHub OAuth 用户授权(评论、编辑评论、删除评论、合并、关闭、反应) -- **Web 配置控制台**(`/admin`)— 基于 ReCloud UI,使用居中路由/分组对话框;通过 GitHub OAuth + 管理员白名单管理路由与分组、查看发送日志 +- **Web 配置控制台**(`/admin`)— 基于 Elysola UI,使用居中路由/分组对话框;通过 GitHub OAuth + 管理员白名单管理路由与分组、查看发送日志 - **Discord Interactions Endpoint**(Ed25519 验签)支持 `/gh` 斜杠命令、消息右键菜单命令、PR 合并/关闭按钮与评论 modal - **Telegram `/gh` 命令**(login/logout/comment/merge/close),通过 Telegram webhook 接收,头像以链接预览卡片呈现 - Cloudflare D1 存储配置(路由/分组)、发送日志、平台账号绑定、去重、投递状态与消息更新追踪 + KV 存储临时状态/缓存/安全令牌 + 可选 R2 存储超大负载 @@ -103,7 +103,7 @@ bunx wrangler dev # 启动本地开发服务器 ] ``` -`target.platform` 选择推送目标:`discord`(默认)、`telegram` 或 `feishu`。Discord 目标需 `target.channelId`(可选 `threadId` 指向子区);Telegram 目标需 `target.chatId`(可选 `topicId` 指向话题);飞书目标需 `target.chatId`(可选 `topicId` 指向子话题)。路由还可设置 `stop: true`(跳过后续路由)。路由隶属于**分组**(D1 `d1_groups`,首次加载时从旧版 KV `config:groups` 同步),分组用于限定管理权限,并可限制哪些组织/用户的事件流入。完整模式见[路由与目标](https://webhooker.docs.worldexecute.me/zh/guide/routes)与[分组与访问控制](https://webhooker.docs.worldexecute.me/zh/guide/groups)指南。 +`target.platform` 选择推送目标:`discord`(默认)、`telegram` 或 `feishu`。Discord 目标需 `target.channelId`(可选 `threadId` 指向子区);Telegram 目标需 `target.chatId`(可选 `topicId` 指向话题);飞书目标需 `target.chatId`(可选 `topicId` 指向子话题)。路由还可设置 `stop: true`(跳过后续路由)。路由隶属于**分组**(D1 `d1_groups`,首次加载时从旧版 KV `config:groups` 同步),分组用于限定管理权限,并可限制哪些组织/用户的事件流入。完整模式见[路由与目标](https://webhooker.docs.elysola.org/zh/guide/routes)与[分组与访问控制](https://webhooker.docs.elysola.org/zh/guide/groups)指南。 ### Web 控制台(`/admin`) @@ -119,7 +119,7 @@ bunx wrangler dev # 启动本地开发服务器 ### 过滤器类型 -所有过滤器均支持纯文本、`*`/`?` 通配符与 `/正则/`(不区分大小写);设置 `exclude: true` 可取反。`field` 过滤器通过 JSONPath(`path`)读取任意载荷字段(数组会展开,任一元素匹配即可),并可用 `op` 指定比较操作符(默认 `eq`);`op: "exists"` 只判断字段是否存在、无需 `match`。过滤器还可通过路由上可选的 `ast`(`all` / `any` / `not` 节点)组合为 AST,以表达默认 AND 列表之外的布尔组合——当 `ast` 存在时优先于 `filters`。路由编辑器提供可视化 AST 构建器、chip 多值输入、无状态试匹配器与命名过滤器片段(存于 D1 `d1_fragments`)。模式语法与完整过滤器参考见[过滤器教程](https://webhooker.docs.worldexecute.me/zh/guide/filters)。 +所有过滤器均支持纯文本、`*`/`?` 通配符与 `/正则/`(不区分大小写);设置 `exclude: true` 可取反。`field` 过滤器通过 JSONPath(`path`)读取任意载荷字段(数组会展开,任一元素匹配即可),并可用 `op` 指定比较操作符(默认 `eq`);`op: "exists"` 只判断字段是否存在、无需 `match`。过滤器还可通过路由上可选的 `ast`(`all` / `any` / `not` 节点)组合为 AST,以表达默认 AND 列表之外的布尔组合——当 `ast` 存在时优先于 `filters`。路由编辑器提供可视化 AST 构建器、chip 多值输入、无状态试匹配器与命名过滤器片段(存于 D1 `d1_fragments`)。模式语法与完整过滤器参考见[过滤器教程](https://webhooker.docs.elysola.org/zh/guide/filters)。 ## API @@ -164,10 +164,10 @@ bunx wrangler dev # 启动本地开发服务器 ## 配置教程 -- **GitHub App** — 创建应用、订阅事件、配置 OAuth 与 _Setup URL_(租户隔离):见 [GitHub App 配置](https://webhooker.docs.worldexecute.me/zh/guide/deployment#github-app-设置) -- **Discord 机器人** — 创建机器人、以 `applications.commands` scope 邀请(组合权限整数 `274877910016`)、配置 Interactions Endpoint:见 [Discord Bot 配置](https://webhooker.docs.worldexecute.me/zh/guide/deployment#discord-bot-设置)。bot 从不连接 Discord Gateway,因此显示为**离线**——消息推送不受影响(始终走 REST)。 -- **Telegram 机器人** — 用 [@BotFather](https://t.me/BotFather) 创建机器人,设置 `TELEGRAM_TOKEN`(可选 `TELEGRAM_WEBHOOK_SECRET`);webhook 由定时任务自动同步:见 [Telegram 机器人配置](https://webhooker.docs.worldexecute.me/zh/guide/deployment#telegram-机器人配置) -- **部署** — KV 命名空间、D1 数据库与迁移(含 0008 存储表)、可选 R2 Bucket 与 Queues、密钥、部署:见[部署指南](https://webhooker.docs.worldexecute.me/zh/guide/deployment) +- **GitHub App** — 创建应用、订阅事件、配置 OAuth 与 _Setup URL_(租户隔离):见 [GitHub App 配置](https://webhooker.docs.elysola.org/zh/guide/deployment#github-app-设置) +- **Discord 机器人** — 创建机器人、以 `applications.commands` scope 邀请(组合权限整数 `274877910016`)、配置 Interactions Endpoint:见 [Discord Bot 配置](https://webhooker.docs.elysola.org/zh/guide/deployment#discord-bot-设置)。bot 从不连接 Discord Gateway,因此显示为**离线**——消息推送不受影响(始终走 REST)。 +- **Telegram 机器人** — 用 [@BotFather](https://t.me/BotFather) 创建机器人,设置 `TELEGRAM_TOKEN`(可选 `TELEGRAM_WEBHOOK_SECRET`);webhook 由定时任务自动同步:见 [Telegram 机器人配置](https://webhooker.docs.elysola.org/zh/guide/deployment#telegram-机器人配置) +- **部署** — KV 命名空间、D1 数据库与迁移(含 0008 存储表)、可选 R2 Bucket 与 Queues、密钥、部署:见[部署指南](https://webhooker.docs.elysola.org/zh/guide/deployment) ### Bot 指令(以本人身份评论 GitHub) @@ -178,7 +178,7 @@ bot 通过定时任务(每 5 分钟)同步注册原生的**斜杠命令**与 /gh comment add|edit|del link:<链接> (或右键通知 → 应用 → GitHub: 添加/编辑/删除评论) ``` -完整参考见[机器人命令指南](https://webhooker.docs.worldexecute.me/zh/guide/commands)。 +完整参考见[机器人命令指南](https://webhooker.docs.elysola.org/zh/guide/commands)。 ## 开发命令 @@ -191,7 +191,7 @@ bun test # 单元测试 ## 支持的事件 -28 个事件格式化器(push、pull_request、issues、workflow_run、release 等)外加 `custom` webhook;不支持的事件回退到通用格式化器。带嵌入亮点的完整表格见[支持的事件](https://webhooker.docs.worldexecute.me/zh/events/supported)。 +28 个事件格式化器(push、pull_request、issues、workflow_run、release 等)外加 `custom` webhook;不支持的事件回退到通用格式化器。带嵌入亮点的完整表格见[支持的事件](https://webhooker.docs.elysola.org/zh/events/supported)。 ## 许可证 diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 8205501..7072cc2 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -1,6 +1,6 @@ @import "tailwindcss"; -/* ReCloud UI-compatible RGB aliases for app-specific Tailwind utilities. */ +/* Elysola UI-compatible RGB aliases for app-specific Tailwind utilities. */ @theme inline { --font-ui: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; diff --git a/app/components/AppToasts.vue b/app/components/AppToasts.vue index 004470d..9315c9b 100644 --- a/app/components/AppToasts.vue +++ b/app/components/AppToasts.vue @@ -1,12 +1,12 @@