mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5326] [MERGED] feat(notifications): event bus architecture with Telegram and SMTP subscribers #5849
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#5849
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/5326
Author: @Ssentiago
Created: 6/14/2026
Status: ✅ Merged
Merged: 6/15/2026
Merged by: @MHSanaei
Base:
main← Head:feat/notifications-eventbus📝 Commits (6)
6e593affeat(notifications): event bus architecture with Telegram and SMTP subscribers67e443eMerge branch 'main' into feat/notifications-eventbusc8a1ad5fixd436374fix(notifications): repair crash/CPU alerts, harden secrets, add node alertsd611784fix(settings): use antd Space orientation instead of deprecated directionf4d0b93i18n(notifications): translate the notification feature into all locales📊 Changes
48 files changed (+3852 additions, -139 deletions)
View changed files
📝
frontend/public/openapi.json(+181 -10)➕
frontend/src/components/ui/EventBusCheckboxes.tsx(+147 -0)📝
frontend/src/components/ui/index.ts(+1 -0)📝
frontend/src/generated/examples.ts(+21 -2)📝
frontend/src/generated/schemas.ts(+112 -10)📝
frontend/src/generated/types.ts(+21 -2)📝
frontend/src/generated/zod.ts(+21 -2)📝
frontend/src/layouts/AppSidebar.tsx(+2 -0)📝
frontend/src/models/setting.ts(+11 -2)📝
frontend/src/pages/api-docs/endpoints.ts(+12 -0)➕
frontend/src/pages/settings/EmailTab.tsx(+137 -0)📝
frontend/src/pages/settings/SettingsPage.tsx(+3 -1)📝
frontend/src/pages/settings/TelegramTab.tsx(+45 -12)📝
frontend/src/schemas/setting.ts(+1 -1)➕
internal/eventbus/bus.go(+123 -0)➕
internal/eventbus/bus_test.go(+199 -0)➕
internal/eventbus/events.go(+64 -0)➕
internal/eventbus/filter.go(+33 -0)📝
internal/web/controller/setting.go(+61 -2)📝
internal/web/entity/entity.go(+22 -10)...and 28 more files
📄 Description
Closes #5188
Summary
Add event bus notification system for 3x-ui panel. Replaces hardcoded Telegram bot notifications with a flexible pub/sub architecture that supports multiple notification channels (Telegram + Email/SMTP).
Why
Previously, notification logic was scattered as direct
SendMsgToTgbotAdmins()calls in separate files (check_cpu_usage.go,tgbot_report.go). Adding a new notification channel (like email) would require modifying every one of those call sites. The event bus decouples publishers from channels — a new subscriber receives all events with zero changes to existing code.What changed
Type of change
Areas affected
Added files
Event Bus Core
internal/eventbus/bus.gointernal/eventbus/bus_test.gointernal/eventbus/events.gointernal/eventbus/filter.goEmail Notifications
internal/web/service/email/email.gointernal/web/service/email/subscriber.gointernal/web/service/email/ratelimiter_test.goTelegram Notifications
internal/web/service/tgbot/tgbot_event.goFrontend
frontend/src/components/ui/EventBusCheckboxes.tsxfrontend/src/pages/settings/EmailTab.tsxModified files
Backend - Event Publishing
internal/xray/process.goOnCrash func(err error)callback field; calls OnCrash when Xray process fails unexpectedly.internal/web/web.gointernal/web/service/xray_metrics.gointernal/web/job/check_cpu_usage.goSendMsgToTgbotAdmins()toEventBus.Publish(EventCPUHigh). Removed tgbot dependency, uses locale.I18n directly.internal/web/job/check_xray_running_job.goEventBusglobal variable.internal/web/service/tgbot/tgbot_report.goUserLoginNotify()to publish EventLoginAttempt to event bus instead of direct Telegram send.internal/web/service/tgbot/tgbot.goEventBusglobal variable.internal/web/service/tgbot/tgbot_send.goTestConnection()method for Telegram bot testing.Backend - Settings & API
internal/web/entity/entity.gointernal/web/service/setting.gointernal/web/controller/setting.goFrontend - Settings
frontend/src/models/setting.tsfrontend/src/pages/settings/TelegramTab.tsxfrontend/src/pages/settings/SettingsPage.tsxfrontend/src/layouts/AppSidebar.tsxfrontend/src/components/ui/index.tsfrontend/src/pages/api-docs/endpoints.tsGenerated files
frontend/public/openapi.jsonfrontend/src/generated/types.tsfrontend/src/generated/zod.tsfrontend/src/generated/schemas.tsfrontend/src/generated/examples.tsi18n (all 13 locale files)
internal/web/translation/en-US.jsoninternal/web/translation/ru-RU.jsoninternal/web/translation/*.json(11 other locales)How was this tested?
Telegram notifications:
Email notifications:
Outbound health notifications:
Xray crash notifications:
Rate limiting:
Unit tests:
Screenshots / recordings
Two tabs in settings - Telegram Bot and Email:

Telegram bot notification settings section:

Email settings section:

Email notification settings section:

Breaking changes
None. The notification system is backward compatible:
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.