Merge remote-tracking branch 'upstream/main' into merge-gramsrv-9106877

This commit is contained in:
onysd 2026-08-03 23:29:20 +03:00
commit ac6a50c5ff
697 changed files with 100880 additions and 8052 deletions

View file

@ -8,7 +8,7 @@ import (
const (
DefaultPublicBaseURL = "https://telesrv.net"
DefaultWebBaseURL = "https://web.telesrv.net"
DefaultWebBaseURL = "https://weba.telesrv.net"
DefaultAppScheme = "telesrv"
DefaultAppName = "telesrv"
DefaultDownloadURL = "https://owpengram.org"
@ -136,6 +136,24 @@ func (b AppLinkBuilder) BuildUsername(username string, query url.Values) string
return b.Build("resolve", query)
}
// AcceptsEntityURL reports whether a raw custom-scheme URL belongs to this
// server's configured app-link namespace. The legacy route-as-host scheme is
// accepted for rollout compatibility; a distinct host-based scheme is limited
// to the exact configured host so arbitrary same-scheme links aren't promoted
// to clickable message entities by the server.
func (b AppLinkBuilder) AcceptsEntityURL(raw string) bool {
parsed, err := url.Parse(raw)
if err != nil || parsed.Opaque != "" || parsed.User != nil || parsed.Hostname() == "" || parsed.Port() != "" {
return false
}
if strings.EqualFold(parsed.Scheme, b.legacyScheme) {
return true
}
return b.baseHost != "" &&
strings.EqualFold(parsed.Scheme, b.baseScheme) &&
strings.EqualFold(parsed.Host, b.baseHost)
}
// MatchesRoute accepts the exact configured host-path form and the retained
// legacy route-as-host form. Query validation remains the caller's concern.
func (b AppLinkBuilder) MatchesRoute(parsed *url.URL, route string) bool {