[PR #5888] [MERGED] fix(clients): include Telegram ID in client list search #6023

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5888
Author: @mrnickson-hue
Created: 7/10/2026
Status: ✅ Merged
Merged: 7/10/2026
Merged by: @MHSanaei

Base: main ← Head: fix/client-search-by-tg-id


📝 Commits (3)

  • 5f28dec fix(clients): include Telegram ID in client list search
  • a188a47 fix(clients): drop explanatory comment, mention Telegram ID in search hint
  • fd92e94 test(clients): remove TgID search test per maintainer request

📊 Changes

14 files changed (+16 additions, -13 deletions)

View changed files

📝 internal/web/service/client_paging.go (+3 -0)
📝 internal/web/translation/ar-EG.json (+1 -1)
📝 internal/web/translation/en-US.json (+1 -1)
📝 internal/web/translation/es-ES.json (+1 -1)
📝 internal/web/translation/fa-IR.json (+1 -1)
📝 internal/web/translation/id-ID.json (+1 -1)
📝 internal/web/translation/ja-JP.json (+1 -1)
📝 internal/web/translation/pt-BR.json (+1 -1)
📝 internal/web/translation/ru-RU.json (+1 -1)
📝 internal/web/translation/tr-TR.json (+1 -1)
📝 internal/web/translation/uk-UA.json (+1 -1)
📝 internal/web/translation/vi-VN.json (+1 -1)
📝 internal/web/translation/zh-CN.json (+1 -1)
📝 internal/web/translation/zh-TW.json (+1 -1)

📄 Description

Summary

Fixes #5880 — searching the client list by Telegram user ID no longer matched, because clientMatchesSearch (internal/web/service/client_paging.go) only checked Email, SubID, Comment, UUID, Password, Auth.

This is a genuine regression, not a field that simply was never included. Before the paged/search backend endpoint was added in #4500, the frontend searched with ObjectUtil.deepSearch() over the entire client object, which recursed into every field — including tgId — since it's just a number that gets toString()'d and substring-matched. Replacing that with a fixed backend candidate list silently dropped Telegram ID from being searchable. Since tgId is normally populated through the panel's own Telegram bot linking flow rather than typed in manually, being able to look a client up by it in the panel is the actual point of the field.

Change

  • clientMatchesSearch now also matches on TgID. It's int64 (0 = unset), so it can't sit in the existing []string candidates array — matched separately via strconv.FormatInt, and skipped when 0 so a needle of "0" doesn't spuriously match every client without a Telegram ID.
  • Added client_search_tgid_test.go: full match, substring match, no false-positive on an unrelated numeric needle, the "0" guard, and confirmation the existing fields still match (no regression).

Test plan

  • go test ./internal/web/service/... — all packages pass
  • go vet ./internal/web/service/... — clean
  • New test TestClientMatchesSearch_TgID covers the fix directly

🔄 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/5888 **Author:** [@mrnickson-hue](https://github.com/mrnickson-hue) **Created:** 7/10/2026 **Status:** ✅ Merged **Merged:** 7/10/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/client-search-by-tg-id` --- ### 📝 Commits (3) - [`5f28dec`](https://github.com/MHSanaei/3x-ui/commit/5f28decd78f7bb9c01756c3ec81d651d1f28ed15) fix(clients): include Telegram ID in client list search - [`a188a47`](https://github.com/MHSanaei/3x-ui/commit/a188a4739e4e59e8beffbd46e1c8068044e13f28) fix(clients): drop explanatory comment, mention Telegram ID in search hint - [`fd92e94`](https://github.com/MHSanaei/3x-ui/commit/fd92e94977f649c4c1f1ab9425ad1112b6e46b43) test(clients): remove TgID search test per maintainer request ### 📊 Changes **14 files changed** (+16 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/client_paging.go` (+3 -0) 📝 `internal/web/translation/ar-EG.json` (+1 -1) 📝 `internal/web/translation/en-US.json` (+1 -1) 📝 `internal/web/translation/es-ES.json` (+1 -1) 📝 `internal/web/translation/fa-IR.json` (+1 -1) 📝 `internal/web/translation/id-ID.json` (+1 -1) 📝 `internal/web/translation/ja-JP.json` (+1 -1) 📝 `internal/web/translation/pt-BR.json` (+1 -1) 📝 `internal/web/translation/ru-RU.json` (+1 -1) 📝 `internal/web/translation/tr-TR.json` (+1 -1) 📝 `internal/web/translation/uk-UA.json` (+1 -1) 📝 `internal/web/translation/vi-VN.json` (+1 -1) 📝 `internal/web/translation/zh-CN.json` (+1 -1) 📝 `internal/web/translation/zh-TW.json` (+1 -1) </details> ### 📄 Description ## Summary Fixes #5880 — searching the client list by Telegram user ID no longer matched, because `clientMatchesSearch` (`internal/web/service/client_paging.go`) only checked `Email, SubID, Comment, UUID, Password, Auth`. This is a genuine regression, not a field that simply was never included. Before the paged/search backend endpoint was added in #4500, the frontend searched with `ObjectUtil.deepSearch()` over the *entire* client object, which recursed into every field — including `tgId` — since it's just a number that gets `toString()`'d and substring-matched. Replacing that with a fixed backend candidate list silently dropped Telegram ID from being searchable. Since `tgId` is normally populated through the panel's own Telegram bot linking flow rather than typed in manually, being able to look a client up by it in the panel is the actual point of the field. ## Change - `clientMatchesSearch` now also matches on `TgID`. It's `int64` (0 = unset), so it can't sit in the existing `[]string` candidates array — matched separately via `strconv.FormatInt`, and skipped when `0` so a needle of `"0"` doesn't spuriously match every client without a Telegram ID. - Added `client_search_tgid_test.go`: full match, substring match, no false-positive on an unrelated numeric needle, the `"0"` guard, and confirmation the existing fields still match (no regression). ## Test plan - [x] `go test ./internal/web/service/...` — all packages pass - [x] `go vet ./internal/web/service/...` — clean - [x] New test `TestClientMatchesSearch_TgID` covers the fix directly --- <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:49 +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#6023
No description provided.