mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-24 04:41:58 +00:00
Revert "fix(sub): keep the client identity on every subscription link (#6098)"
Some checks are pending
CI / go-test (push) Waiting to run
CI / postgres-durable-first (push) Waiting to run
CI / codegen (push) Waiting to run
CI / govulncheck (push) Waiting to run
CI / race (push) Waiting to run
CI / fuzz-smoke (push) Waiting to run
CI / golangci (push) Waiting to run
CI / frontend (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run
Release 3X-UI / Publish rolling dev release (push) Blocked by required conditions
Some checks are pending
CI / go-test (push) Waiting to run
CI / postgres-durable-first (push) Waiting to run
CI / codegen (push) Waiting to run
CI / govulncheck (push) Waiting to run
CI / race (push) Waiting to run
CI / fuzz-smoke (push) Waiting to run
CI / golangci (push) Waiting to run
CI / frontend (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run
Release 3X-UI / Publish rolling dev release (push) Blocked by required conditions
This reverts commitc004c18d90. Showing {{EMAIL}}/{{USERNAME}} on the first subscription-body link only is intentional, not an oversight in876d55f2. Restoring the behaviour and the tests that pin it. Making the identity tokens configurable is the sanctioned route for the operators asking for them on every link (#5935), rather than flipping the default for everyone.
This commit is contained in:
parent
8bc00d1e90
commit
fd17255f1d
2 changed files with 20 additions and 18 deletions
|
|
@ -481,6 +481,15 @@ var connectionTokens = map[string]bool{
|
|||
|
||||
var displayRemoveTokens = mergeTokenSets(usageInfoTokens, connectionTokens)
|
||||
|
||||
// firstLinkOnlyBodyTokens are stripped from every subscription-body link after a
|
||||
// client's first one: the usage/info tokens plus the per-client EMAIL/USERNAME
|
||||
// identity. A client app needs the email once, so repeating it on every link of
|
||||
// the same subscription is noise — show it on the first link only, like traffic.
|
||||
var firstLinkOnlyBodyTokens = mergeTokenSets(usageInfoTokens, map[string]bool{
|
||||
"EMAIL": true,
|
||||
"USERNAME": true,
|
||||
})
|
||||
|
||||
func mergeTokenSets(sets ...map[string]bool) map[string]bool {
|
||||
out := make(map[string]bool)
|
||||
for _, set := range sets {
|
||||
|
|
@ -551,7 +560,7 @@ func (s *SubService) effectiveTemplate(email string) string {
|
|||
s.usageShown = map[string]bool{}
|
||||
}
|
||||
if s.usageShown[email] {
|
||||
return filterRemarkTemplate(translated, usageInfoTokens)
|
||||
return filterRemarkTemplate(translated, firstLinkOnlyBodyTokens)
|
||||
}
|
||||
s.usageShown[email] = true
|
||||
return translated
|
||||
|
|
|
|||
|
|
@ -386,8 +386,8 @@ func TestIdentityTokenBodyVsDisplay(t *testing.T) {
|
|||
|
||||
body := &SubService{remarkTemplate: tmpl, subscriptionBody: true, usageShown: map[string]bool{}}
|
||||
_ = body.genTemplatedRemark(inbound, client, "", "ws") // first link consumes the usage block
|
||||
if second := body.genTemplatedRemark(inbound, client, "", "ws"); !strings.Contains(second, "john@x") {
|
||||
t.Fatalf("repeat body link %q must keep the identity token", second)
|
||||
if second := body.genTemplatedRemark(inbound, client, "", "ws"); strings.Contains(second, "john@x") {
|
||||
t.Fatalf("repeat body link %q must drop the identity token", second)
|
||||
}
|
||||
|
||||
display := &SubService{remarkTemplate: tmpl, subscriptionBody: false}
|
||||
|
|
@ -624,7 +624,7 @@ func TestUsageOnFirstLinkOnly_SingleBracket(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestEmailOnEveryLink(t *testing.T) {
|
||||
func TestEmailOnFirstLinkOnly(t *testing.T) {
|
||||
s := &SubService{
|
||||
remarkTemplate: "{{INBOUND}} {{EMAIL}}|📊{{TRAFFIC_LEFT}}",
|
||||
subscriptionBody: true,
|
||||
|
|
@ -640,22 +640,15 @@ func TestEmailOnEveryLink(t *testing.T) {
|
|||
}
|
||||
client := model.Client{Email: "alice@x"}
|
||||
first := s.genTemplatedRemark(inbound, client, "", "ws")
|
||||
s.usageShown["alice@x"] = true
|
||||
second := s.genTemplatedRemark(inbound, client, "", "ws")
|
||||
third := s.genTemplatedRemark(inbound, client, "", "ws")
|
||||
for i, remark := range []string{first, second, third} {
|
||||
if !strings.Contains(remark, "alice@x") {
|
||||
t.Fatalf("link %d must carry the client email: %q", i+1, remark)
|
||||
}
|
||||
if !strings.Contains(remark, "DE") {
|
||||
t.Fatalf("link %d must carry the inbound name: %q", i+1, remark)
|
||||
}
|
||||
if !strings.Contains(first, "alice@x") {
|
||||
t.Fatalf("first link should carry email: %q", first)
|
||||
}
|
||||
if !strings.Contains(first, "📊") {
|
||||
t.Fatalf("first link should carry the usage block: %q", first)
|
||||
if strings.Contains(second, "alice@x") {
|
||||
t.Fatalf("second link must not carry email: %q", second)
|
||||
}
|
||||
for i, remark := range []string{second, third} {
|
||||
if strings.Contains(remark, "📊") {
|
||||
t.Fatalf("repeat link %d must still drop the usage block: %q", i+2, remark)
|
||||
}
|
||||
if !strings.Contains(second, "DE") {
|
||||
t.Fatalf("second link should still carry the inbound name: %q", second)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue