summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/account.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-04-06 13:19:55 +0200
committerLibravatar GitHub <noreply@github.com>2023-04-06 12:19:55 +0100
commitc54510bc7407f22b58bd56ad65b2e3f60e8e4dc5 (patch)
tree26b1650686a8be480cd3115e3c2d814aa50e91c0 /internal/federation/dereferencing/account.go
parent[bugfix] Always serialize orderedItems as array (#1673) (diff)
downloadgotosocial-c54510bc7407f22b58bd56ad65b2e3f60e8e4dc5.tar.xz
[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
Diffstat (limited to 'internal/federation/dereferencing/account.go')
-rw-r--r--internal/federation/dereferencing/account.go30
1 files changed, 2 insertions, 28 deletions
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) {