[PR #6986] [MERGED] fix(tgbot): restore the admin's client link and QR buttons #6562

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6986
Author: @muditagrawal2007
Created: 10/28/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @MHSanaei

Base: main ← Head: fix/tgbot-admin-client-links


📝 Commits (4)

  • b5ff50b fix(tgbot): restore the admin's client link and QR buttons
  • 8e98631 Merge remote-tracking branch 'origin/main' into pr/6986
  • 5768d0d docs(tgbot): drop the mocked-up client card screenshots
  • 2d09348 test(tgbot): keep the admin client card tests with the other screen tests

📊 Changes

6 files changed (+163 additions, -6 deletions)

View changed files

📝 docs/content/docs/en/operations/telegram-bot.mdx (+5 -2)
📝 docs/content/docs/fa/operations/telegram-bot.mdx (+2 -0)
📝 docs/content/docs/ru/operations/telegram-bot.mdx (+5 -3)
📝 docs/content/docs/zh/operations/telegram-bot.mdx (+3 -1)
📝 internal/web/service/tgbot/screen_legacy.go (+6 -0)
📝 internal/web/service/tgbot/screens_test.go (+142 -0)

📄 Description

Summary

Restores the admin's ability to open a client's subscription link and QR code from the Telegram bot. The v3.11.0 bot rebuild (#6760) replaced the admin menu, and the client card — the one screen every admin path ends at — was left with no link or QR button. An invite link was the only way to hand a config over, and it needs the client to reach Telegram first, which is exactly what a client in a censored network cannot do yet.

The card now carries two buttons again: 🔗 Links (subscription URL + individual links) and 🔳 QR code (the codes as one picture).

v3.11.0 this PR
Admin → any client's subscription URL ✕ unreachable ✓ one tap
Admin → any client's individual links ✕ unreachable ✓ one tap
Admin → any client's QR code ✕ unreachable ✓ one tap

Why

Closes #6984.

The reporter's catch-22 is the real blocker: the client needs the VPN to reach Telegram, and needs Telegram to get the VPN. Before v3.11.0 the admin menu had three buttons for exactly this — Subscription settings, Individual links and QR code — and the rebuild dropped all three. 15fee2a0^:internal/web/service/tgbot/tgbot_send.go:50-54 had them; internal/web/service/tgbot/screen_view.go:38-88 does not.

The screens themselves were never removed:

  • screenClientLinks (screen_client_views.go:154) draws the subscription URL and the individual links,
  • screenClientQR (screen_client_views.go:209) draws the codes as one picture,
  • the client_sub_links / client_qr_links callbacks are still routed for admins (tgbot_router.go:414-422) and still carry the ownership check for everyone else (tgbot_router.go:1211).

Only the entry point was lost: the card every admin route ends at had no button leading to them. So the fix is the two buttons — no new handler, no new state, no new callback.

The flow, end to end

Home → 👥 Clients → 👥 All Clients → (client browser) → client card → 🔗 Links → subscription URL

The card is also reachable without the inline browser via /usage <email>, so the flow works whether or not inline mode is enabled in @BotFather.

What an admin gets

  • 🔗 Links — the subscription URL as copyable text, plus a button for the individual vless:// / trojan:// / … links
  • 🔳 QR code — the subscription, JSON and per-app codes as a single picture, ready to forward over any messenger

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

New Go tests — internal/web/service/tgbot/tgbot_admin_client_links_test.go:

  • TestAdminClientCardOffersTheLinksAndQRCode — the admin's client card carries client_sub_links <email> and client_qr_links <email>. This is the regression test: it fails on v3.11.0 with "the admin's client card lacks client_sub_links …".
  • TestAdminTappingTheClientCardLinksDrawsTheSubscription — the button is not decoration: the callback the card itself offers is fed back through the router, and the links screen must come up carrying the subscription URL.
  • TestAdminTappingTheClientCardQRCodeDrawsTheCode — same for the QR sheet.

All three were written first and watched fail for the reported reason; the fix is 6 lines in internal/web/service/tgbot/screen_legacy.go.

Locally

make test-go        # green, including the tgbot package
golangci-lint run   # 0 issues
make gen-check      # no generated-file drift (no API change)

By hand — as an admin: /start → 👥 Clients → 👥 All Clients → pick a client → 🔗 Links shows the subscription URL and 🔳 QR code shows the picture. As a client: /start still shows only your own links, and a link callback carrying another client's email is still refused (TestClientLinkCallbackRefusesForeignClient).

Screenshots / recordings

The admin's client card, before and after:

The admin's client card in v3.11.0 — no link or QR button

The admin's client card after the fix — a Links and a QR code button

What the admin lands on:

The subscription screen the admin opens from the client card

(The mockups are rendered from the bot's real keyboard — the buttons are the ones clientRows builds, not a drawing.)

Breaking changes

None. The two buttons use callbacks the bot already routed, and no client-facing behaviour changes: a client's own menu is untouched, and the ownership check that refuses a foreign client's link callback is unchanged.

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: npm run lint, npm run typecheck, and npm run build pass.
  • 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/6986 **Author:** [@muditagrawal2007](https://github.com/muditagrawal2007) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/tgbot-admin-client-links` --- ### 📝 Commits (4) - [`b5ff50b`](https://github.com/MHSanaei/3x-ui/commit/b5ff50b7e093ef57134146412c332e78522729dd) fix(tgbot): restore the admin's client link and QR buttons - [`8e98631`](https://github.com/MHSanaei/3x-ui/commit/8e986316966a7c2b8f536339ede2b55f1f493023) Merge remote-tracking branch 'origin/main' into pr/6986 - [`5768d0d`](https://github.com/MHSanaei/3x-ui/commit/5768d0d9cd69a085614b3936f97347f2070247ee) docs(tgbot): drop the mocked-up client card screenshots - [`2d09348`](https://github.com/MHSanaei/3x-ui/commit/2d09348c0c80ca60bedc5f35e4d5019497de3e2f) test(tgbot): keep the admin client card tests with the other screen tests ### 📊 Changes **6 files changed** (+163 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/operations/telegram-bot.mdx` (+5 -2) 📝 `docs/content/docs/fa/operations/telegram-bot.mdx` (+2 -0) 📝 `docs/content/docs/ru/operations/telegram-bot.mdx` (+5 -3) 📝 `docs/content/docs/zh/operations/telegram-bot.mdx` (+3 -1) 📝 `internal/web/service/tgbot/screen_legacy.go` (+6 -0) 📝 `internal/web/service/tgbot/screens_test.go` (+142 -0) </details> ### 📄 Description ## Summary Restores the admin's ability to open a client's **subscription link** and **QR code** from the Telegram bot. The v3.11.0 bot rebuild (#6760) replaced the admin menu, and the client card — the one screen every admin path ends at — was left with no link or QR button. An invite link was the only way to hand a config over, and it needs the client to reach Telegram first, which is exactly what a client in a censored network cannot do yet. The card now carries two buttons again: **🔗 Links** (subscription URL + individual links) and **🔳 QR code** (the codes as one picture). | | v3.11.0 | this PR | |---|---|---| | Admin → any client's subscription URL | ✕ unreachable | ✓ one tap | | Admin → any client's individual links | ✕ unreachable | ✓ one tap | | Admin → any client's QR code | ✕ unreachable | ✓ one tap | ## Why Closes #6984. The reporter's catch-22 is the real blocker: the client needs the VPN to reach Telegram, and needs Telegram to get the VPN. Before v3.11.0 the admin menu had three buttons for exactly this — *Subscription settings*, *Individual links* and *QR code* — and the rebuild dropped all three. `15fee2a0^:internal/web/service/tgbot/tgbot_send.go:50-54` had them; `internal/web/service/tgbot/screen_view.go:38-88` does not. The screens themselves were never removed: - `screenClientLinks` (`screen_client_views.go:154`) draws the subscription URL and the individual links, - `screenClientQR` (`screen_client_views.go:209`) draws the codes as one picture, - the `client_sub_links` / `client_qr_links` callbacks are still routed for admins (`tgbot_router.go:414-422`) and still carry the ownership check for everyone else (`tgbot_router.go:1211`). Only the **entry point** was lost: the card every admin route ends at had no button leading to them. So the fix is the two buttons — no new handler, no new state, no new callback. ### The flow, end to end `Home → 👥 Clients → 👥 All Clients → (client browser) → client card → 🔗 Links → subscription URL` The card is also reachable without the inline browser via `/usage <email>`, so the flow works whether or not inline mode is enabled in @BotFather. ### What an admin gets - **🔗 Links** — the subscription URL as copyable text, plus a button for the individual `vless://` / `trojan://` / … links - **🔳 QR code** — the subscription, JSON and per-app codes as a single picture, ready to forward over any messenger ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [x] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [x] Telegram bot ## How was this tested? **New Go tests** — `internal/web/service/tgbot/tgbot_admin_client_links_test.go`: - `TestAdminClientCardOffersTheLinksAndQRCode` — the admin's client card carries `client_sub_links <email>` and `client_qr_links <email>`. This is the regression test: it fails on `v3.11.0` with *"the admin's client card lacks `client_sub_links …`"*. - `TestAdminTappingTheClientCardLinksDrawsTheSubscription` — the button is not decoration: the callback the card itself offers is fed back through the router, and the links screen must come up carrying the subscription URL. - `TestAdminTappingTheClientCardQRCodeDrawsTheCode` — same for the QR sheet. All three were written first and watched fail for the reported reason; the fix is 6 lines in `internal/web/service/tgbot/screen_legacy.go`. **Locally** ```bash make test-go # green, including the tgbot package golangci-lint run # 0 issues make gen-check # no generated-file drift (no API change) ``` **By hand** — as an admin: `/start` → **👥 Clients** → **👥 All Clients** → pick a client → **🔗 Links** shows the subscription URL and **🔳 QR code** shows the picture. As a client: `/start` still shows only your own links, and a link callback carrying another client's email is still refused (`TestClientLinkCallbackRefusesForeignClient`). ## Screenshots / recordings The admin's client card, before and after: ![The admin's client card in v3.11.0 — no link or QR button](https://raw.githubusercontent.com/muditagrawal2007/3x-ui/fix/tgbot-admin-client-links/docs/public/images/tgbot-admin-client-card-before.png) ![The admin's client card after the fix — a Links and a QR code button](https://raw.githubusercontent.com/muditagrawal2007/3x-ui/fix/tgbot-admin-client-links/docs/public/images/tgbot-admin-client-card-after.png) What the admin lands on: ![The subscription screen the admin opens from the client card](https://raw.githubusercontent.com/muditagrawal2007/3x-ui/fix/tgbot-admin-client-links/docs/public/images/tgbot-admin-subscription-links.png) (The mockups are rendered from the bot's real keyboard — the buttons are the ones `clientRows` builds, not a drawing.) ## Breaking changes None. The two buttons use callbacks the bot already routed, and no client-facing behaviour changes: a client's own menu is untouched, and the ownership check that refuses a foreign client's link callback is unchanged. ## 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: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] 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 changed title from [PR #6986] fix(tgbot): restore the admin's client link and QR buttons to [PR #6986] [MERGED] fix(tgbot): restore the admin's client link and QR buttons 2026-11-07 14:34:00 +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#6562
No description provided.