From a4c64bd56d26d82253a8a7534fc96742a7815ed0 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Tue, 31 May 2022 16:57:43 +0200 Subject: [PATCH] rework finger again, final form --- internal/federation/dereferencing/finger.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/federation/dereferencing/finger.go b/internal/federation/dereferencing/finger.go index 7e8a0700f..9613d2975 100644 --- a/internal/federation/dereferencing/finger.go +++ b/internal/federation/dereferencing/finger.go @@ -59,19 +59,19 @@ func (d *deref) fingerRemoteAccount(ctx context.Context, username string, target return } - var username, accountDomain string - username, accountDomain, err = util.ExtractWebfingerParts(resp.Subject) + _, accountDomain, err = util.ExtractWebfingerParts(resp.Subject) + if err != nil { + err = fmt.Errorf("fingerRemoteAccount: error extracting webfinger subject parts: %s", err) + } - // look through the links for the first one that matches "application/activity+json", this is what we need + // look through the links for the first one that matches what we need for _, l := range resp.Links { - if strings.EqualFold(l.Type, "application/activity+json") && l.Href != "" && l.Rel == "self" { - accountURI, err = url.Parse(l.Href) - if err != nil { - err = fmt.Errorf("fingerRemoteAccount: couldn't parse url %s: %s", l.Href, err) + if l.Rel == "self" && (strings.EqualFold(l.Type, "application/activity+json") || strings.EqualFold(l.Type, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")) { + if uri, thiserr := url.Parse(l.Href); thiserr == nil && (uri.Scheme == "http" || uri.Scheme == "https") { + // found it! + accountURI = uri return } - // found it! - return } }