mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-13 13:57:59 +00:00
Refactor URL construction to use pre-configured URIs if available, otherwise fallback to default scheme and host.
This commit is contained in:
parent
5370b6943a
commit
328ba3b45e
1 changed files with 25 additions and 2 deletions
|
|
@ -2267,6 +2267,8 @@ func (t *Tgbot) buildSubscriptionURLs(email string) (string, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather settings to construct absolute URLs
|
// Gather settings to construct absolute URLs
|
||||||
|
subURI, _ := t.settingService.GetSubURI()
|
||||||
|
subJsonURI, _ := t.settingService.GetSubJsonURI()
|
||||||
subDomain, _ := t.settingService.GetSubDomain()
|
subDomain, _ := t.settingService.GetSubDomain()
|
||||||
subPort, _ := t.settingService.GetSubPort()
|
subPort, _ := t.settingService.GetSubPort()
|
||||||
subPath, _ := t.settingService.GetSubPath()
|
subPath, _ := t.settingService.GetSubPath()
|
||||||
|
|
@ -2314,8 +2316,29 @@ func (t *Tgbot) buildSubscriptionURLs(email string) (string, string, error) {
|
||||||
subJsonPath = subJsonPath + "/"
|
subJsonPath = subJsonPath + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
subURL := fmt.Sprintf("%s://%s%s%s", scheme, host, subPath, client.SubID)
|
var subURL string
|
||||||
subJsonURL := fmt.Sprintf("%s://%s%s%s", scheme, host, subJsonPath, client.SubID)
|
var subJsonURL string
|
||||||
|
|
||||||
|
// If pre-configured URIs are available, use them directly
|
||||||
|
if subURI != "" {
|
||||||
|
if !strings.HasSuffix(subURI, "/") {
|
||||||
|
subURI = subURI + "/"
|
||||||
|
}
|
||||||
|
subURL = fmt.Sprintf("%s%s", subURI, client.SubID)
|
||||||
|
} else {
|
||||||
|
subURL = fmt.Sprintf("%s://%s%s%s", scheme, host, subPath, client.SubID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if subJsonURI != "" {
|
||||||
|
if !strings.HasSuffix(subJsonURI, "/") {
|
||||||
|
subJsonURI = subJsonURI + "/"
|
||||||
|
}
|
||||||
|
subJsonURL = fmt.Sprintf("%s%s", subJsonURI, client.SubID)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
subJsonURL = fmt.Sprintf("%s://%s%s%s", scheme, host, subJsonPath, client.SubID)
|
||||||
|
}
|
||||||
|
|
||||||
if !subJsonEnable {
|
if !subJsonEnable {
|
||||||
subJsonURL = ""
|
subJsonURL = ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue