[PR #7033] [MERGED] fix(tgbot): let clients page their screens and see usage per account #6588

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7033
Author: @orshih6
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei

Base: main ← Head: contribot/issue-7032


📝 Commits (2)

  • 2d06179 fix(tgbot): let clients page their screens and see usage per account
  • 1805551 Merge branch 'main' into contribot/issue-7032

📊 Changes

3 files changed (+76 additions, -9 deletions)

View changed files

📝 internal/web/service/tgbot/screen_client_views.go (+18 -9)
📝 internal/web/service/tgbot/screens_test.go (+55 -0)
📝 internal/web/service/tgbot/tgbot_router.go (+3 -0)

📄 Description

A client bound to several accounts gets a home screen long enough to be split into pages. But pg:next, pg:prev and pg:none were not in isClientSelfCallback, so the gate in answerCallback silently dropped every page tap from a non-admin. Paging only re-renders the screen already stored for the caller's own chat and carries no target of its own, so it is now allowed for clients alongside home and hide.

The second problem: tapping one of those accounts opened screenClientLinks, which showed only the subscription URL. The links screen still offered the "client card" button, which sends the admin-only client_get_usage callback, so for a client it was another dead button. The old check hid that button only when the client had exactly one subscription. ownSubscriptionOnly is now ownClientTraffic: for a non-admin who owns the email, it returns that account's traffic. The links screen shows that usage at the top (the same clientInfoMsg fields the home screen shows) and leaves out the admin card. Ownership of the email is already checked in the router before this screen is drawn. Admins see the screen exactly as before.

Tests in screens_test.go:

  • TestClientCanTurnPages: the gate allows pg:*, and a non-admin tapping next on a multi-page screen moves it to page 2.
  • TestLinksScreenShowsUsageToItsOwner: a client with two accounts sees usage on the links screen and gets no client_get_usage button.

Both fail without the change. go test ./internal/web/service/tgbot/, go vet and gofmt pass.

Fixes #7032


This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.


🔄 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/7033 **Author:** [@orshih6](https://github.com/orshih6) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `contribot/issue-7032` --- ### 📝 Commits (2) - [`2d06179`](https://github.com/MHSanaei/3x-ui/commit/2d06179815cdad864e23c411ce27ec6ca5cc63df) fix(tgbot): let clients page their screens and see usage per account - [`1805551`](https://github.com/MHSanaei/3x-ui/commit/1805551f4a96a955ae33202570284a2c54d22806) Merge branch 'main' into contribot/issue-7032 ### 📊 Changes **3 files changed** (+76 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/tgbot/screen_client_views.go` (+18 -9) 📝 `internal/web/service/tgbot/screens_test.go` (+55 -0) 📝 `internal/web/service/tgbot/tgbot_router.go` (+3 -0) </details> ### 📄 Description A client bound to several accounts gets a home screen long enough to be split into pages. But `pg:next`, `pg:prev` and `pg:none` were not in `isClientSelfCallback`, so the gate in `answerCallback` silently dropped every page tap from a non-admin. Paging only re-renders the screen already stored for the caller's own chat and carries no target of its own, so it is now allowed for clients alongside `home` and `hide`. The second problem: tapping one of those accounts opened `screenClientLinks`, which showed only the subscription URL. The links screen still offered the "client card" button, which sends the admin-only `client_get_usage` callback, so for a client it was another dead button. The old check hid that button only when the client had exactly one subscription. `ownSubscriptionOnly` is now `ownClientTraffic`: for a non-admin who owns the email, it returns that account's traffic. The links screen shows that usage at the top (the same `clientInfoMsg` fields the home screen shows) and leaves out the admin card. Ownership of the email is already checked in the router before this screen is drawn. Admins see the screen exactly as before. Tests in `screens_test.go`: - `TestClientCanTurnPages`: the gate allows `pg:*`, and a non-admin tapping next on a multi-page screen moves it to page 2. - `TestLinksScreenShowsUsageToItsOwner`: a client with two accounts sees usage on the links screen and gets no `client_get_usage` button. Both fail without the change. `go test ./internal/web/service/tgbot/`, `go vet` and `gofmt` pass. Fixes #7032 --- _This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like._ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #7033] fix(tgbot): let clients page their screens and see usage per account to [PR #7033] [MERGED] fix(tgbot): let clients page their screens and see usage per account 2026-11-07 14:34:06 +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#6588
No description provided.