Clean up and change to double knock request helper

This commit is contained in:
Melody Becker 2025-05-22 17:02:14 +02:00
parent d8dd5eb671
commit 66fbf9afbb
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI

View file

@ -419,25 +419,14 @@ func ImportRemoteAccountByAPUrl(apUrl string) (*models.User, error) {
// Reason: Implementations should be switching over from cavage to the final implementation
// (rfc9421) slowly, but might not support the latter. Double-knocking will work
// around this
response, err = webshared.RequestSignedRFC9421("GET", apUrl, nil, linstromActor)
response, _, err = webshared.RequestSigned("GET", apUrl, nil, linstromActor)
if err != nil {
return nil, other.Error("activitypub", "failed to complete rfc9421 signed request", err)
return nil, other.Error("activitypub", "failed to complete signed request", err)
}
body, _ := io.ReadAll(response.Body)
response.Body.Close()
if response.StatusCode != 200 {
log.Debug().
Int("status-code", response.StatusCode).
Msg("RFC9421 signed request failed, trying cavage signature")
response, err = webshared.RequestSignedCavage("GET", apUrl, nil, linstromActor)
if err != nil {
return nil, other.Error("activitypub", "failed to complete cavage signed request", err)
}
body, _ = io.ReadAll(response.Body)
response.Body.Close()
if response.StatusCode != 200 {
return nil, fmt.Errorf("activitypub: invalid status code: %v", response.StatusCode)
}
return nil, fmt.Errorf("activitypub: invalid status code: %v", response.StatusCode)
}
var data inboundImportUser
err = json.Unmarshal(body, &data)