This commit is contained in:
2026-06-03 21:53:31 +02:00
parent 2b4326b553
commit 1a425a1b0d
15 changed files with 377 additions and 97 deletions
+15 -2
View File
@@ -175,7 +175,7 @@ func TestQRZ(ctx context.Context, client *http.Client, apiKey string) (string, e
if err != nil {
return "", fmt.Errorf("qrz: bad response: %w", err)
}
status := strings.ToUpper(strings.TrimSpace(vals.Get("STATUS")))
status := qrzStatusField(vals)
if status == "AUTH" || status == "FAIL" {
reason := strings.TrimSpace(vals.Get("REASON"))
if reason == "" {
@@ -201,7 +201,11 @@ func parseQRZResponse(body string) (UploadResult, error) {
if err != nil {
return UploadResult{}, fmt.Errorf("qrz: bad response %q: %w", body, err)
}
status := strings.ToUpper(strings.TrimSpace(vals.Get("STATUS")))
// The QRZ Logbook API returns the outcome in RESULT (=OK/FAIL/AUTH).
// Accept STATUS as a fallback for robustness, but RESULT is the real
// field — reading only STATUS made every INSERT (incl. successful ones)
// look like it failed with an empty status.
status := qrzStatusField(vals)
reason := strings.TrimSpace(vals.Get("REASON"))
logID := strings.TrimSpace(vals.Get("LOGID"))
@@ -222,6 +226,15 @@ func parseQRZResponse(body string) (UploadResult, error) {
}
}
// qrzStatusField returns the QRZ outcome code, preferring RESULT (the
// Logbook API's real field) and falling back to STATUS.
func qrzStatusField(vals url.Values) string {
if v := strings.ToUpper(strings.TrimSpace(vals.Get("RESULT"))); v != "" {
return v
}
return strings.ToUpper(strings.TrimSpace(vals.Get("STATUS")))
}
// isDuplicateReason recognises the various phrasings QRZ uses when a QSO is
// already present.
func isDuplicateReason(reason string) bool {