mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-05 21:06:38 +08:00
fix organizer diagnostics and site integrations
This commit is contained in:
+20
-1
@@ -321,7 +321,11 @@ func ApplySiteAuthHeaders(req *http.Request, site *model.Site) {
|
||||
}
|
||||
case "api_key":
|
||||
if site.APIKey != "" {
|
||||
req.Header.Set("x-api-key", site.APIKey)
|
||||
if isYemaPTSite(site) {
|
||||
req.Header.Set("Authorization", site.APIKey)
|
||||
} else {
|
||||
req.Header.Set("x-api-key", site.APIKey)
|
||||
}
|
||||
}
|
||||
case "auth_header":
|
||||
if site.AuthHeader != "" {
|
||||
@@ -335,6 +339,21 @@ func ApplySiteAuthHeaders(req *http.Request, site *model.Site) {
|
||||
}
|
||||
}
|
||||
|
||||
func isYemaPTSite(site *model.Site) bool {
|
||||
if site == nil {
|
||||
return false
|
||||
}
|
||||
if strings.EqualFold(strings.TrimSpace(site.Type), "yemapt") {
|
||||
return true
|
||||
}
|
||||
u, err := url.Parse(strings.TrimSpace(site.URL))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
host := strings.ToLower(u.Hostname())
|
||||
return host == "yemapt.org" || strings.HasSuffix(host, ".yemapt.org")
|
||||
}
|
||||
|
||||
// GetPageSource fetches a page with browser-like headers.
|
||||
// Returns (pageSource, cookies, error).
|
||||
func GetPageSource(url string, site *model.Site, timeout int, log *zap.Logger) (string, string, error) {
|
||||
|
||||
Reference in New Issue
Block a user