From c54510bc7407f22b58bd56ad65b2e3f60e8e4dc5 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:19:55 +0200 Subject: [bugfix] Normalize status content (don't parse status content as IRI) (#1665) * start fannying about * finish up Normalize * tidy up * pin to tag * move errors about just a little bit --- internal/federation/dereferencing/account.go | 30 ++-------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'internal/federation/dereferencing/account.go') diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go index 0ce35b0e4..4795db733 100644 --- a/internal/federation/dereferencing/account.go +++ b/internal/federation/dereferencing/account.go @@ -357,39 +357,13 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url. // dereferenceAccountable calls remoteAccountID with a GET request, and tries to parse whatever // it finds as something that an account model can be constructed out of. -// -// Will work for Person, Application, or Service models. func (d *deref) dereferenceAccountable(ctx context.Context, transport transport.Transport, remoteAccountID *url.URL) (ap.Accountable, error) { b, err := transport.Dereference(ctx, remoteAccountID) if err != nil { - return nil, fmt.Errorf("DereferenceAccountable: error deferencing %s: %w", remoteAccountID.String(), err) - } - - m := make(map[string]interface{}) - if err := json.Unmarshal(b, &m); err != nil { - return nil, fmt.Errorf("DereferenceAccountable: error unmarshalling bytes into json: %w", err) - } - - t, err := streams.ToType(ctx, m) - if err != nil { - return nil, fmt.Errorf("DereferenceAccountable: error resolving json into ap vocab type: %w", err) - } - - //nolint:forcetypeassert - switch t.GetTypeName() { - case ap.ActorApplication: - return t.(vocab.ActivityStreamsApplication), nil - case ap.ActorGroup: - return t.(vocab.ActivityStreamsGroup), nil - case ap.ActorOrganization: - return t.(vocab.ActivityStreamsOrganization), nil - case ap.ActorPerson: - return t.(vocab.ActivityStreamsPerson), nil - case ap.ActorService: - return t.(vocab.ActivityStreamsService), nil + return nil, fmt.Errorf("dereferenceAccountable: error deferencing %s: %w", remoteAccountID.String(), err) } - return nil, newErrWrongType(fmt.Errorf("DereferenceAccountable: type name %s not supported as Accountable", t.GetTypeName())) + return ap.ResolveAccountable(ctx, b) } func (d *deref) fetchRemoteAccountAvatar(ctx context.Context, tsport transport.Transport, avatarURL string, accountID string) (string, error) { -- cgit v1.2.3