From 69eb4d6b0af746b47ccba0b03b3b1f0ca8711fd1 Mon Sep 17 00:00:00 2001 From: CDN18 Date: Mon, 10 Jun 2024 13:57:22 +0800 Subject: [PATCH] fix: do second actor deref from main-key endpoint against publickey.Owner --- activitypub.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/activitypub.go b/activitypub.go index 8fb0716..6a3b0a1 100644 --- a/activitypub.go +++ b/activitypub.go @@ -822,13 +822,28 @@ func getActor(app *App, actorIRI string) (*activitystreams.Person, *RemoteUser, log.Info("Not found; fetching actor %s remotely", actorIRI) actorResp, err := resolveIRI(app.cfg.App.Host, actorIRI) if err != nil { - log.Error("Unable to get actor! %v", err) + log.Error("Unable to get base actor! %v", err) return nil, nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't fetch actor."} } if err := unmarshalActor(actorResp, actor); err != nil { - log.Error("Unable to unmarshal actor! %v", err) + log.Error("Unable to unmarshal base actor! %v", err) return nil, nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't parse actor."} } + baseActor := &activitystreams.Person{} + if err := unmarshalActor(actorResp, baseActor); err != nil { + log.Error("Unable to unmarshal actual actor! %v", err) + return nil, nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't parse actual actor."} + } + // Fetch the actual actor using the owner field from the publicKey object + actualActorResp, err := resolveIRI(app.cfg.App.Host, baseActor.PublicKey.Owner) + if err != nil { + log.Error("Unable to get actual actor! %v", err) + return nil, nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't fetch actual actor."} + } + if err := unmarshalActor(actualActorResp, actor); err != nil { + log.Error("Unable to unmarshal actual actor! %v", err) + return nil, nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't parse actual actor."} + } } else { return nil, nil, err }