diff options
| author | mr-shura <65220775+mr-shura@users.noreply.github.com> | 2026-01-19 14:33:17 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-19 14:33:17 +0300 |
| commit | 328ba3b45eb2108abe8a985f9c060ba4187e1596 (patch) | |
| tree | 72e4f7425cd2ea0db1653543b02044f8fcc45be0 /web | |
| parent | 5370b6943af5e17388f5ae97605899526278ea3a (diff) | |
fix Telegram bot ignores reverse proxy setting #3673 (#3684)
Refactor URL construction to use pre-configured URIs if available, otherwise fallback to default scheme and host.
Diffstat (limited to 'web')
| -rw-r--r-- | web/service/tgbot.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 3a98dcb4..96299050 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -2267,6 +2267,8 @@ func (t *Tgbot) buildSubscriptionURLs(email string) (string, string, error) { } // Gather settings to construct absolute URLs + subURI, _ := t.settingService.GetSubURI() + subJsonURI, _ := t.settingService.GetSubJsonURI() subDomain, _ := t.settingService.GetSubDomain() subPort, _ := t.settingService.GetSubPort() subPath, _ := t.settingService.GetSubPath() @@ -2314,8 +2316,29 @@ func (t *Tgbot) buildSubscriptionURLs(email string) (string, string, error) { subJsonPath = subJsonPath + "/" } - subURL := fmt.Sprintf("%s://%s%s%s", scheme, host, subPath, client.SubID) - subJsonURL := fmt.Sprintf("%s://%s%s%s", scheme, host, subJsonPath, client.SubID) + var subURL string + 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 { subJsonURL = "" } |
