mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6108] [CLOSED] feat(notifications): add webhook subscriber for event bus #6081
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6081
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6108
Author: @lordfre
Created: 7/26/2026
Status: ❌ Closed
Base:
main← Head:main📝 Commits (1)
757ce36feat(notifications): add webhook subscriber for event bus📊 Changes
22 files changed (+1390 additions, -18 deletions)
View changed files
📝
frontend/public/openapi.json(+120 -2)➕
frontend/src/components/ui/notifications/WebhookNotifications.stories.tsx(+85 -0)➕
frontend/src/components/ui/notifications/WebhookNotifications.tsx(+112 -0)📝
frontend/src/generated/examples.ts(+15 -2)📝
frontend/src/generated/schemas.ts(+62 -2)📝
frontend/src/generated/types.ts(+13 -0)📝
frontend/src/generated/zod.ts(+13 -0)📝
frontend/src/layouts/AppSidebar.tsx(+1 -0)📝
frontend/src/models/setting.ts(+13 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+7 -0)📝
frontend/src/pages/settings/SettingsPage.tsx(+3 -1)➕
frontend/src/pages/settings/WebhookTab.tsx(+122 -0)📝
internal/web/controller/setting.go(+41 -7)📝
internal/web/entity/entity.go(+8 -0)📝
internal/web/service/setting.go(+79 -4)➕
internal/web/service/webhook/subscriber.go(+57 -0)➕
internal/web/service/webhook/subscriber_test.go(+102 -0)➕
internal/web/service/webhook/webhook.go(+153 -0)➕
internal/web/service/webhook/webhook_test.go(+321 -0)📝
internal/web/translation/en-US.json(+22 -0)...and 2 more files
📄 Description
Summary
Adds a generic HTTP webhook notification channel to the event bus, alongside the existing Telegram and SMTP subscribers. Panel events (outbound/node health, Xray crashes, CPU/RAM thresholds, login attempts) can now be delivered as a signed JSON POST to any user-configured URL.
Why
Telegram is blocked or unreliable in some regions/networks, and not every operator wants email. A generic webhook lets events be routed into whatever the operator already uses — Discord/Slack via a relay, n8n, a custom endpoint, etc. — without depending on Telegram connectivity.
Closes #5727
Type of change
Areas affected
How was this tested?
Backend
internal/web/service/webhook/webhook_test.goandsubscriber_test.go: payload shape, HMAC-SHA256 signing (present/absent based on configured secret), non-2xx response handling, missing-URL error path, CPU/Memory threshold gating (above/below/disabled), andTestConnection()success/failure — all against anhttptest.Serverrecording requests.internal/web/controller/setting_webhook_test.go:POST /panel/api/setting/testWebhooksuccess and downstream-failure cases viahttptest+ a fresh sqlite DB per test.eventbus.RateLimiter(per event-type + source, 1-minute cooldown,login.attemptbypasses it) — covered by subscriber tests (rate-limited, per-source independence, login bypass).webhook.site/ncat -llistener → confirmed POST body,X-Webhook-Eventheader, andX-Webhook-Signatureheader (when secret set) → toggled individual event checkboxes and confirmed only enabled events fire → verified secret-clear checkbox actually removes the stored secret after Save.Frontend
WebhookNotifications.stories.tsx(Storybook) mirroringEmailNotifications.stories.tsx— event group selection states (nothing/thresholds/infra/all).npm run buildpasses with the newAllSettingfields (webhookEnable,webhookURL,webhookSecret,hasWebhookSecret,clearWebhookSecret,webhookEnabledEvents,webhookCpu,webhookMemory).Screenshots / recordings
Breaking changes
None. Webhook is disabled by default (
webhookEnable: false); existing installs are unaffected until an operator opts in.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.