[PR #7086] feat(wechat): add WeCom and webhook notifications #6641

Open
opened 2026-11-07 14:34:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7086
Author: @3356153957
Created: 11/5/2026
Status: 🔄 Open

Base: main ← Head: codex/wechat-notifications-pr


📝 Commits (1)

  • 6d7155f feat(wechat): add independent alerts and scheduled reports

📊 Changes

55 files changed (+3985 additions, -60 deletions)

View changed files

📝 docs/content/docs/en/operations/meta.json (+1 -0)
➕ docs/content/docs/en/operations/wechat-notifications.mdx (+62 -0)
📝 docs/content/docs/en/reference/api/settings.mdx (+10 -1)
📝 docs/content/docs/zh/operations/meta.json (+1 -0)
➕ docs/content/docs/zh/operations/wechat-notifications.mdx (+60 -0)
➕ docs/public/images/wechat-settings.png (+0 -0)
📝 docs/public/openapi.json (+128 -2)
📝 frontend/public/openapi.json (+128 -2)
➕ frontend/src/components/ui/notifications/WechatNotifications.stories.tsx (+96 -0)
➕ frontend/src/components/ui/notifications/WechatNotifications.tsx (+160 -0)
📝 frontend/src/generated/examples.ts (+24 -2)
📝 frontend/src/generated/schemas.ts (+98 -2)
📝 frontend/src/generated/types.ts (+22 -0)
📝 frontend/src/generated/zod.ts (+22 -0)
📝 frontend/src/layouts/AppSidebar.tsx (+6 -0)
📝 frontend/src/models/setting.ts (+15 -1)
📝 frontend/src/pages/api-docs/endpoints.ts (+6 -0)
📝 frontend/src/pages/settings/SettingsPage.tsx (+11 -1)
➕ frontend/src/pages/settings/WechatTab.stories.tsx (+62 -0)
➕ frontend/src/pages/settings/WechatTab.tsx (+235 -0)

...and 35 more files

📄 Description

Summary

Add an optional WeChat notification channel with its own settings, event filters, language, CPU/memory thresholds, and scheduled reports. It supports WeCom group robots directly and a documented HTTPS webhook protocol for external gateways, without enabling Telegram or changing other channels' configuration.

Why

Administrators can receive panel alerts through their WeCom group or an existing WeChat gateway. Personal WeChat requires an external bridge; this PR does not include a personal WeChat login, bot protocol, or a particular gateway implementation.

The channel is disabled by default and sends text only. Reports contain resource usage, deduplicated client traffic/quota summaries, and inbound/client counts. It does not send subscription links, client configuration files, or database backups, and has no remote commands.

Type of change

  • New feature
  • Documentation
  • Tests

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Statistics / traffic reporting (read only)

Implementation

  • Add the WeChat settings tab, saved-configuration test endpoint, notification controls, 14 locale entries, generated API definitions, and English/Chinese documentation.
  • Redact both the URL and Bearer token on settings reads; preserve blank secrets unless explicitly cleared. Read the delivery destination and credential in one database snapshot during concurrent settings rotation.
  • Use certificate-verified HTTPS, connection-time SSRF checks, bounded requests/responses, and no redirects. Custom gateways receive a stable UUID/body for one bounded transport/5xx retry; receivers must deduplicate and own final delivery. WeCom uses its official endpoint, UTF-8-safe message splitting, rate spacing, and errcode verification without automatic retry.
  • Reload report schedules and metric jobs on settings saves, retaining unchanged schedules. Client summaries use case-insensitive identity deduplication and normalized-client limit fallback when runtime snapshots omit quota or expiration; limit queries are bounded and do not modify counters.

How was this tested?

  • Linux/Go 1.27.3: before the final report-identity correction below, go build -p 1 ./... and go test -json -p 1 -shuffle=on -count=1 ./... passed: 54 packages, 6,285 passing test/subtest events and 70 skips. Environment-dependent tests (including PostgreSQL tests without a configured DSN) remain skipped.
  • Final client-identity correction: real SQLite regressions were first reproduced, then passed with -race -shuffle=on. Coverage includes ASCII/Unicode case variants, shared-client deduplication, per-field zero-value fallback, nonzero runtime limits, 501 identities, query parameter limits, context cancellation, and unchanged database rows. After this report-only correction, the final committed source was rebuilt on Linux and all five affected backend packages were rerun (2,808 passing test/subtest events, 47 environment-dependent skips); the complete WeChat provider race suite passed again (43 passing events). All test inputs were verified against the frozen source manifest.
  • Targeted race tests passed for the provider, settings, controller, report job, and scheduler integration. Regression tests cover atomic destination/token rotation, secret preservation/clearing, response validation, retry identity, redirects, alert filtering/cooldown, quota edge cases, and unchanged report schedules.
  • Frontend: typecheck, lint, format check, production build, Storybook build, and all three test projects passed: 232 files / 2,109 tests (unit 1,453; components 543; Chromium stories 113). API/Zod generation was repeated without changes. The local Windows browser runner needed an ignored temporary IPv4 API-host override; repository test configuration is unchanged.
  • Documentation: typecheck, lint, format check, 112 tests, production build, matching panel/docs OpenAPI, and stable generated references passed. Existing desktop/mobile inbound keyboard checks also passed. Production dependency audit passes the configured high-severity threshold.
  • Manual local Chromium panel: switch delivery mode, enter example credentials, save, refresh, confirm secrets load blank while marked configured, disable, explicitly clear, save, and verify clearing persisted. Also checked the responsive stories. No real credentials are present in screenshots.

The direct WeCom API behavior is covered by HTTP transport tests; a live enterprise group robot was not used. Windows full-suite probes also reproduce the existing IPv6 socket restriction on clean upstream; the complete backend suite was therefore run on Linux, followed by the final-source validation detailed above.

Screenshots

WeChat settings

Breaking changes

None. Existing notification settings retain their behavior. No dependency changes or database schema migration.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior.
  • Linux backend build and test validation is complete, with full-suite and final-source rerun scopes detailed above.
  • Frontend lint, typecheck, build, tests, and Storybook build pass.
  • User-facing setup and API documentation are updated.
  • My commit follows the project's existing message style.
  • There are no unrelated changes, runtime artifacts, or private deployment settings in this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/7086 **Author:** [@3356153957](https://github.com/3356153957) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/wechat-notifications-pr` --- ### 📝 Commits (1) - [`6d7155f`](https://github.com/MHSanaei/3x-ui/commit/6d7155f2b392390db485736b481d9c20b3e8e111) feat(wechat): add independent alerts and scheduled reports ### 📊 Changes **55 files changed** (+3985 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/operations/meta.json` (+1 -0) ➕ `docs/content/docs/en/operations/wechat-notifications.mdx` (+62 -0) 📝 `docs/content/docs/en/reference/api/settings.mdx` (+10 -1) 📝 `docs/content/docs/zh/operations/meta.json` (+1 -0) ➕ `docs/content/docs/zh/operations/wechat-notifications.mdx` (+60 -0) ➕ `docs/public/images/wechat-settings.png` (+0 -0) 📝 `docs/public/openapi.json` (+128 -2) 📝 `frontend/public/openapi.json` (+128 -2) ➕ `frontend/src/components/ui/notifications/WechatNotifications.stories.tsx` (+96 -0) ➕ `frontend/src/components/ui/notifications/WechatNotifications.tsx` (+160 -0) 📝 `frontend/src/generated/examples.ts` (+24 -2) 📝 `frontend/src/generated/schemas.ts` (+98 -2) 📝 `frontend/src/generated/types.ts` (+22 -0) 📝 `frontend/src/generated/zod.ts` (+22 -0) 📝 `frontend/src/layouts/AppSidebar.tsx` (+6 -0) 📝 `frontend/src/models/setting.ts` (+15 -1) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+6 -0) 📝 `frontend/src/pages/settings/SettingsPage.tsx` (+11 -1) ➕ `frontend/src/pages/settings/WechatTab.stories.tsx` (+62 -0) ➕ `frontend/src/pages/settings/WechatTab.tsx` (+235 -0) _...and 35 more files_ </details> ### 📄 Description ## Summary Add an optional WeChat notification channel with its own settings, event filters, language, CPU/memory thresholds, and scheduled reports. It supports WeCom group robots directly and a documented HTTPS webhook protocol for external gateways, without enabling Telegram or changing other channels' configuration. ## Why Administrators can receive panel alerts through their WeCom group or an existing WeChat gateway. Personal WeChat requires an external bridge; this PR does not include a personal WeChat login, bot protocol, or a particular gateway implementation. The channel is disabled by default and sends text only. Reports contain resource usage, deduplicated client traffic/quota summaries, and inbound/client counts. It does not send subscription links, client configuration files, or database backups, and has no remote commands. ## Type of change - [x] New feature - [x] Documentation - [x] Tests ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [x] Statistics / traffic reporting (read only) ## Implementation - Add the WeChat settings tab, saved-configuration test endpoint, notification controls, 14 locale entries, generated API definitions, and English/Chinese documentation. - Redact both the URL and Bearer token on settings reads; preserve blank secrets unless explicitly cleared. Read the delivery destination and credential in one database snapshot during concurrent settings rotation. - Use certificate-verified HTTPS, connection-time SSRF checks, bounded requests/responses, and no redirects. Custom gateways receive a stable UUID/body for one bounded transport/5xx retry; receivers must deduplicate and own final delivery. WeCom uses its official endpoint, UTF-8-safe message splitting, rate spacing, and `errcode` verification without automatic retry. - Reload report schedules and metric jobs on settings saves, retaining unchanged schedules. Client summaries use case-insensitive identity deduplication and normalized-client limit fallback when runtime snapshots omit quota or expiration; limit queries are bounded and do not modify counters. ## How was this tested? - Linux/Go 1.27.3: before the final report-identity correction below, `go build -p 1 ./...` and `go test -json -p 1 -shuffle=on -count=1 ./...` passed: 54 packages, 6,285 passing test/subtest events and 70 skips. Environment-dependent tests (including PostgreSQL tests without a configured DSN) remain skipped. - Final client-identity correction: real SQLite regressions were first reproduced, then passed with `-race -shuffle=on`. Coverage includes ASCII/Unicode case variants, shared-client deduplication, per-field zero-value fallback, nonzero runtime limits, 501 identities, query parameter limits, context cancellation, and unchanged database rows. After this report-only correction, the final committed source was rebuilt on Linux and all five affected backend packages were rerun (2,808 passing test/subtest events, 47 environment-dependent skips); the complete WeChat provider race suite passed again (43 passing events). All test inputs were verified against the frozen source manifest. - Targeted race tests passed for the provider, settings, controller, report job, and scheduler integration. Regression tests cover atomic destination/token rotation, secret preservation/clearing, response validation, retry identity, redirects, alert filtering/cooldown, quota edge cases, and unchanged report schedules. - Frontend: typecheck, lint, format check, production build, Storybook build, and all three test projects passed: **232 files / 2,109 tests** (unit 1,453; components 543; Chromium stories 113). API/Zod generation was repeated without changes. The local Windows browser runner needed an ignored temporary IPv4 API-host override; repository test configuration is unchanged. - Documentation: typecheck, lint, format check, **112 tests**, production build, matching panel/docs OpenAPI, and stable generated references passed. Existing desktop/mobile inbound keyboard checks also passed. Production dependency audit passes the configured high-severity threshold. - Manual local Chromium panel: switch delivery mode, enter example credentials, save, refresh, confirm secrets load blank while marked configured, disable, explicitly clear, save, and verify clearing persisted. Also checked the responsive stories. No real credentials are present in screenshots. The direct WeCom API behavior is covered by HTTP transport tests; a live enterprise group robot was not used. Windows full-suite probes also reproduce the existing IPv6 socket restriction on clean upstream; the complete backend suite was therefore run on Linux, followed by the final-source validation detailed above. ## Screenshots ![WeChat settings](https://raw.githubusercontent.com/3356153957/3x-ui/6d7155f2b392390db485736b481d9c20b3e8e111/docs/public/images/wechat-settings.png) ## Breaking changes None. Existing notification settings retain their behavior. No dependency changes or database schema migration. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior. - [x] Linux backend build and test validation is complete, with full-suite and final-source rerun scopes detailed above. - [x] Frontend lint, typecheck, build, tests, and Storybook build pass. - [x] User-facing setup and API documentation are updated. - [x] My commit follows the project's existing message style. - [x] There are no unrelated changes, runtime artifacts, or private deployment settings in this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6641
No description provided.