[PR #6163] [MERGED] feat(sub): add template variables to subscription metadata (title, support and profile URLs, announcement) #6125

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6163
Author: @isultanov99
Created: 7/30/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @MHSanaei

Base: main ← Head: subscription-metadata-placeholders


📝 Commits (1)

  • cd00a55 feat(sub): add template variables to subscription metadata

📊 Changes

22 files changed (+457 additions, -108 deletions)

View changed files

📝 frontend/src/components/form/RemarkTemplateField.tsx (+53 -24)
📝 frontend/src/components/form/RemarkVarPicker.tsx (+5 -3)
📝 frontend/src/lib/remark/remarkVariables.ts (+16 -3)
📝 frontend/src/pages/settings/SubscriptionGeneralTab.tsx (+24 -7)
📝 frontend/src/test/remark-template-field.test.tsx (+29 -0)
📝 internal/sub/controller.go (+27 -19)
➕ internal/sub/placeholders.go (+118 -0)
➕ internal/sub/placeholders_test.go (+132 -0)
📝 internal/sub/service.go (+1 -0)
📝 internal/web/translation/ar-EG.json (+4 -4)
📝 internal/web/translation/en-US.json (+4 -4)
📝 internal/web/translation/es-ES.json (+4 -4)
📝 internal/web/translation/fa-IR.json (+4 -4)
📝 internal/web/translation/id-ID.json (+4 -4)
📝 internal/web/translation/ja-JP.json (+4 -4)
📝 internal/web/translation/pt-BR.json (+4 -4)
📝 internal/web/translation/ru-RU.json (+4 -4)
📝 internal/web/translation/tr-TR.json (+4 -4)
📝 internal/web/translation/uk-UA.json (+4 -4)
📝 internal/web/translation/vi-VN.json (+4 -4)

...and 2 more files

📄 Description

Summary

This adds opt-in template variables to subscription metadata fields:

  • Subscription Title
  • Support URL
  • Profile URL
  • Announce

The goal is to let operators personalize the text and links that VPN clients show around a subscription, without changing the generated proxy links themselves. The metadata picker is intentionally limited to stable client identity tokens: {{EMAIL}}, {{ID}}, {{SHORT_ID}}, {{SUB_ID}}, and {{TELEGRAM_ID}}.

Why

These fields are useful places for support and account-context links.
A private network can show a friendly title per user and open a pre-filled support chat that already includes the client subscription ID.
The same pattern also works for larger deployments that route support requests through Telegram, WhatsApp, or a helpdesk form.

Examples

  • Subscription: your_own_vpn — {{EMAIL}}
  • Support link: https://t.me/your_own_vpn_support?text=Hello!%20I%27ve%20got%20a%20problem.%20My%20Subscription%20ID%20is%20{{SUB_ID}}
  • Support link: https://wa.me/your_own_vpn_support?text=Hello!%20I%27ve%20got%20a%20problem.%20My%20Subscription%20ID%20is%20{{SUB_ID}}
  • Profile URL: https://yourownvpn.com/account/{{ID}}

Implementation Notes

  • Reuses the existing remark variable picker and preview UI.
  • Restricts subscription metadata fields to identity tokens only.
  • Leaves fields without variables on the existing fast path.
  • Leaves unsupported metadata tokens literal, so existing text like {{IMPORTANT}} is preserved while per-inbound, traffic, time, or connection fields are not expanded into profile headers or support URLs.
  • Percent-encodes substituted token values in Support URL and Profile URL fields.

Testing

  • go test ./internal/sub
  • go build ./...
  • cd frontend && ./node_modules/.bin/tsc --noEmit
  • cd frontend && npm exec eslint -- src/components/form/RemarkTemplateField.tsx src/components/form/RemarkVarPicker.tsx src/lib/remark/remarkVariables.ts src/pages/settings/SubscriptionGeneralTab.tsx src/test/remark-template-field.test.tsx
  • cd frontend && CI=1 STORYBOOK_DISABLE_TELEMETRY=1 npm run test -- --run src/test/remark-template-field.test.tsx --pool=forks --testTimeout=30000
  • cd frontend && npm run build

🔄 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/6163 **Author:** [@isultanov99](https://github.com/isultanov99) **Created:** 7/30/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `subscription-metadata-placeholders` --- ### 📝 Commits (1) - [`cd00a55`](https://github.com/MHSanaei/3x-ui/commit/cd00a55a2abed7694cf20f483c4bdd08227c04bc) feat(sub): add template variables to subscription metadata ### 📊 Changes **22 files changed** (+457 additions, -108 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/components/form/RemarkTemplateField.tsx` (+53 -24) 📝 `frontend/src/components/form/RemarkVarPicker.tsx` (+5 -3) 📝 `frontend/src/lib/remark/remarkVariables.ts` (+16 -3) 📝 `frontend/src/pages/settings/SubscriptionGeneralTab.tsx` (+24 -7) 📝 `frontend/src/test/remark-template-field.test.tsx` (+29 -0) 📝 `internal/sub/controller.go` (+27 -19) ➕ `internal/sub/placeholders.go` (+118 -0) ➕ `internal/sub/placeholders_test.go` (+132 -0) 📝 `internal/sub/service.go` (+1 -0) 📝 `internal/web/translation/ar-EG.json` (+4 -4) 📝 `internal/web/translation/en-US.json` (+4 -4) 📝 `internal/web/translation/es-ES.json` (+4 -4) 📝 `internal/web/translation/fa-IR.json` (+4 -4) 📝 `internal/web/translation/id-ID.json` (+4 -4) 📝 `internal/web/translation/ja-JP.json` (+4 -4) 📝 `internal/web/translation/pt-BR.json` (+4 -4) 📝 `internal/web/translation/ru-RU.json` (+4 -4) 📝 `internal/web/translation/tr-TR.json` (+4 -4) 📝 `internal/web/translation/uk-UA.json` (+4 -4) 📝 `internal/web/translation/vi-VN.json` (+4 -4) _...and 2 more files_ </details> ### 📄 Description ## Summary This adds opt-in template variables to subscription metadata fields: - Subscription Title - Support URL - Profile URL - Announce The goal is to let operators personalize the text and links that VPN clients show around a subscription, without changing the generated proxy links themselves. The metadata picker is intentionally limited to stable client identity tokens: `{{EMAIL}}`, `{{ID}}`, `{{SHORT_ID}}`, `{{SUB_ID}}`, and `{{TELEGRAM_ID}}`. ## Why These fields are useful places for support and account-context links. A private network can show a friendly title per user and open a pre-filled support chat that already includes the client subscription ID. The same pattern also works for larger deployments that route support requests through Telegram, WhatsApp, or a helpdesk form. ## Examples - Subscription: `your_own_vpn — {{EMAIL}}` - Support link: `https://t.me/your_own_vpn_support?text=Hello!%20I%27ve%20got%20a%20problem.%20My%20Subscription%20ID%20is%20{{SUB_ID}}` - Support link: `https://wa.me/your_own_vpn_support?text=Hello!%20I%27ve%20got%20a%20problem.%20My%20Subscription%20ID%20is%20{{SUB_ID}}` - Profile URL: `https://yourownvpn.com/account/{{ID}}` ## Implementation Notes - Reuses the existing remark variable picker and preview UI. - Restricts subscription metadata fields to identity tokens only. - Leaves fields without variables on the existing fast path. - Leaves unsupported metadata tokens literal, so existing text like `{{IMPORTANT}}` is preserved while per-inbound, traffic, time, or connection fields are not expanded into profile headers or support URLs. - Percent-encodes substituted token values in Support URL and Profile URL fields. ## Testing - `go test ./internal/sub` - `go build ./...` - `cd frontend && ./node_modules/.bin/tsc --noEmit` - `cd frontend && npm exec eslint -- src/components/form/RemarkTemplateField.tsx src/components/form/RemarkVarPicker.tsx src/lib/remark/remarkVariables.ts src/pages/settings/SubscriptionGeneralTab.tsx src/test/remark-template-field.test.tsx` - `cd frontend && CI=1 STORYBOOK_DISABLE_TELEMETRY=1 npm run test -- --run src/test/remark-template-field.test.tsx --pool=forks --testTimeout=30000` - `cd frontend && npm run build` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:32 +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#6125
No description provided.