mirror of
https://gitlab.melroy.org/melroy/fediresolve.git
synced 2025-06-07 11:58:55 +00:00
Improve performance
This commit is contained in:
parent
8e5a08ab5f
commit
e56d6c9c41
2 changed files with 5 additions and 3 deletions
|
@ -187,6 +187,8 @@ func (r *Resolver) fetchActorData(actorURL string) ([]byte, error) {
|
|||
}
|
||||
|
||||
// extractPublicKey extracts the public key ID from actor data
|
||||
// TODO: We are actually now extracting the ID not the public key pem....
|
||||
// Lets see if we can improve this, without breaking the signing.
|
||||
func (r *Resolver) extractPublicKey(data []byte) (string, error) {
|
||||
// Try to find the attributedTo URL
|
||||
actorURL := gjson.GetBytes(data, "attributedTo").String()
|
||||
|
|
|
@ -201,12 +201,12 @@ func (r *Resolver) resolveCanonicalActivityPub(objectURL string, depth int) (str
|
|||
return "", fmt.Errorf("too many canonical redirects (possible loop)")
|
||||
}
|
||||
fmt.Printf("Fetching ActivityPub object for canonical resolution: %s\n", objectURL)
|
||||
jsonData, err := r.fetchActivityPubObjectRaw(objectURL)
|
||||
raw, err := r.fetchActivityPubObjectRaw(objectURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var data map[string]interface{}
|
||||
if err := json.Unmarshal(jsonData, &data); err != nil {
|
||||
if err := json.Unmarshal(raw, &data); err != nil {
|
||||
return "", fmt.Errorf("error parsing ActivityPub JSON: %v", err)
|
||||
}
|
||||
idVal, ok := data["id"].(string)
|
||||
|
@ -215,7 +215,7 @@ func (r *Resolver) resolveCanonicalActivityPub(objectURL string, depth int) (str
|
|||
return r.resolveCanonicalActivityPub(idVal, depth+1)
|
||||
}
|
||||
// If no id or already canonical, format and return using helpers.go
|
||||
formatted, err := formatResult(jsonData)
|
||||
formatted, err := formatResult(raw)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error formatting ActivityPub object: %v", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue