[PR #5816] [CLOSED] fix(tgbot): resolve Telegram usage lookup by clients.tg_id #5996

Closed
opened 2026-11-02 04:05:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5816
Author: @rqzbeh
Created: 7/5/2026
Status: ❌ Closed

Base: main ← Head: fix/tgbot-compact-tgid


📝 Commits (2)

  • be222fb fix(tgbot): resolve Telegram usage lookup by clients.tg_id
  • 53cc3ec fix(tgbot): merge tg_id and settings email sources

📊 Changes

2 files changed (+184 additions, -18 deletions)

View changed files

📝 internal/web/service/inbound_client_traffic_test.go (+148 -0)
📝 internal/web/service/inbound_traffic.go (+36 -18)

📄 Description

Summary

Fix Telegram bot usage lookup when inbound settings JSON stores tgId without a space after the colon (common after node sync/import).

Why

Closes #5805. The bot used settings LIKE '%"tgId": 123%', which misses compact "tgId":123 and returned no client traffic.

Type of change

  • Bug fix

Areas affected

  • Telegram bot
  • Database / migrations (read path on normalized clients.tg_id)

How was this tested?

  • go test -shuffle=on -count=1 ./internal/web/service -run GetClientTrafficTgBot
  • TestGetClientTrafficTgBotFallsBackToInboundSettings (legacy settings-only rows)
  • TestGetClientTrafficTgBotLegacyCompactJSON (compact JSON, no clients row)

Screenshots / recordings

N/A

Breaking changes

None

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: N/A
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into 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/5816 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 7/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/tgbot-compact-tgid` --- ### 📝 Commits (2) - [`be222fb`](https://github.com/MHSanaei/3x-ui/commit/be222fbf77c02c0084c71e65d208ee6ce231b90a) fix(tgbot): resolve Telegram usage lookup by clients.tg_id - [`53cc3ec`](https://github.com/MHSanaei/3x-ui/commit/53cc3ec64e994d65889cde3f876f2362b5e3d7b2) fix(tgbot): merge tg_id and settings email sources ### 📊 Changes **2 files changed** (+184 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/inbound_client_traffic_test.go` (+148 -0) 📝 `internal/web/service/inbound_traffic.go` (+36 -18) </details> ### 📄 Description ## Summary Fix Telegram bot usage lookup when inbound `settings` JSON stores `tgId` without a space after the colon (common after node sync/import). ## Why Closes #5805. The bot used `settings LIKE '%"tgId": 123%'`, which misses compact `"tgId":123` and returned no client traffic. ## Type of change - [x] Bug fix ## Areas affected - [x] Telegram bot - [x] Database / migrations (read path on normalized `clients.tg_id`) ## How was this tested? - `go test -shuffle=on -count=1 ./internal/web/service -run GetClientTrafficTgBot` - `TestGetClientTrafficTgBotFallsBackToInboundSettings` (legacy settings-only rows) - `TestGetClientTrafficTgBotLegacyCompactJSON` (compact JSON, no `clients` row) ## Screenshots / recordings N/A ## Breaking changes None ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: N/A - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:36 +07:00
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#5996
No description provided.