From e56d6c9c41e8c747679682827063fe22147fb6c3 Mon Sep 17 00:00:00 2001 From: Melroy van den Berg Date: Fri, 25 Apr 2025 01:10:36 +0200 Subject: [PATCH] Improve performance --- resolver/helpers.go | 2 ++ resolver/resolver.go | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resolver/helpers.go b/resolver/helpers.go index 5289dfd..d4aa3ca 100644 --- a/resolver/helpers.go +++ b/resolver/helpers.go @@ -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() diff --git a/resolver/resolver.go b/resolver/resolver.go index 9e75658..8e4b191 100644 --- a/resolver/resolver.go +++ b/resolver/resolver.go @@ -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) }