mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5453] [Bug]: telegram bot send mass spam messages regarding a user's account expiration date #3815
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#3815
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?
Originally created by @vrcher on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5453
Describe the bug
When the Telegram bot sends me a notification with a report on the server and the dashboard, duplicate messages appear.
Clients whose subscriptions are about to expire receive a message as many times as the number of linked incoming connections they have.
For example, if client “user1” has 15 incoming connections, that means at midnight I’ll receive 15 messages—one for each user—stating that their subscription is about to expire. This is extremely inconvenient; I don’t need multiple identical messages for a single user, regardless of how many nodes or connections they have.
How to reproduce the problem
Create a user
Add 5 connections to the user
Set the expiration period to 1 day
Check the Telegram message based on your notification settings in the dashboard
Receive 5 messages notifying you that the expiration period is ending
Expected behavior
1 message and 1 button for the user
Actual behavior
mass spam messages regarding a user's account expiration date
Relevant logs
Screenshots
3x-ui version
3.3.1
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 22.04
Which parts of the panel are affected?
Telegram bot
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 20, 2026):
The duplicate notifications are a confirmed bug in
internal/web/service/tgbot/tgbot_report.go.Root cause
ClientTrafficrows in the database have aUNIQUEconstraint onemail(client_traffic.goline 9), so there is only one traffic row per client email regardless of how many inbounds the client belongs to. GORM loads this row on the inbound that "owns" it (byInboundId). To make the UI reflect multi-inbound membership correctly,GetAllInbounds()callsenrichClientStats()→backfillClientStats(), which appends that same row to theClientStatsslice of every inbound the client is listed in.In
getExhausted()(the periodic admin report, lines 186–281), the code then walks all inbounds returned byGetAllInbounds()and accumulates every entry it finds ininbound.ClientStatsinto a flatexhaustedClientsslice — with no email-based deduplication. A client in N inbounds therefore appears N times in that slice, and N entries are written into the output string.SendMsgToTgbot()(line 95 intgbot_send.go) splits any message longer than 2 000 characters on\r\n\r\nboundaries and sends each chunk as a separate Telegram message. BecauseclientInfoMsgappends\r\nafter every field and the outer loop adds another\r\nafter each entry, consecutive entries are separated by\r\n\r\n— exactly the split delimiter. Once the total output exceeds 2 000 characters the repeated entries become separate Telegram messages, one per inbound the client belongs to.Which function is affected
getExhausted()— the admin notification. The client-facing path (notifyExhausted()) is not affected because it deduplicates by Telegram chat ID using thechatIDsDoneslice (line 302), ensuring each Telegram account receives at most one message per report cycle regardless of how many inbounds its email appears in.Workaround until a fix is released
There is no safe runtime workaround. To reduce the immediate noise you can lower the "Expire Diff" threshold in Telegram bot settings so fewer clients qualify, but this only reduces the volume of duplicates, not the duplication itself.
Suggested fix
Add email-based deduplication when building
exhaustedClientsingetExhausted():The same guard should be applied to
disabledClientsto prevent duplicate entries there as well.Versions confirmed affected: v3.3.1 (latest as of this triage).
This response was generated automatically; a maintainer may follow up.
@MHSanaei commented on GitHub (Jun 20, 2026):
Fixed in
1259c20e.Root cause: a client linked to multiple inbounds has one
ClientStatsrow per inbound, all sharing the same email. The admin's exhausted/expiration report (getExhausted) appended every row, so a user on 15 inbounds was listed 15 times — 15 info blocks and 15 buttons — which Telegram split into multiple messages, appearing as spam.The report now deduplicates by email, so each client is reported exactly once regardless of how many inbounds carry them. (The per-client notification path already deduped by email, so only the admin report was affected.)