mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-29 14:37:13 +00:00
fix(tgbot): dedupe exhausted-client report by email (#5453)
A client linked to N inbounds has one ClientStats row per inbound, all sharing the same email. getExhausted appended every row, so the admin expiration/traffic report listed the same user once per inbound (N info blocks and N buttons), which Telegram split into multiple messages. Track seen emails and report each client once.
This commit is contained in:
@@ -206,6 +206,7 @@ func (t *Tgbot) getExhausted(chatId int64) {
|
|||||||
logger.Warning("Unable to load Inbounds", err)
|
logger.Warning("Unable to load Inbounds", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seenClients := make(map[string]bool)
|
||||||
for _, inbound := range inbounds {
|
for _, inbound := range inbounds {
|
||||||
if inbound.Enable {
|
if inbound.Enable {
|
||||||
if (inbound.ExpiryTime > 0 && (inbound.ExpiryTime-now < exDiff)) ||
|
if (inbound.ExpiryTime > 0 && (inbound.ExpiryTime-now < exDiff)) ||
|
||||||
@@ -214,6 +215,10 @@ func (t *Tgbot) getExhausted(chatId int64) {
|
|||||||
}
|
}
|
||||||
if len(inbound.ClientStats) > 0 {
|
if len(inbound.ClientStats) > 0 {
|
||||||
for _, client := range inbound.ClientStats {
|
for _, client := range inbound.ClientStats {
|
||||||
|
if seenClients[client.Email] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seenClients[client.Email] = true
|
||||||
if client.Enable {
|
if client.Enable {
|
||||||
if (client.ExpiryTime > 0 && (client.ExpiryTime-now < exDiff)) ||
|
if (client.ExpiryTime > 0 && (client.ExpiryTime-now < exDiff)) ||
|
||||||
(client.Total > 0 && (client.Total-(client.Up+client.Down) < trDiff)) {
|
(client.Total > 0 && (client.Total-(client.Up+client.Down) < trDiff)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user