summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/status.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/federation/dereferencing/status.go')
-rw-r--r--internal/federation/dereferencing/status.go75
1 files changed, 2 insertions, 73 deletions
diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go
index 8e202d585..fe07be23a 100644
--- a/internal/federation/dereferencing/status.go
+++ b/internal/federation/dereferencing/status.go
@@ -19,14 +19,11 @@ package dereferencing
import (
"context"
- "encoding/json"
"errors"
"fmt"
"net/url"
"strings"
- "github.com/superseriousbusiness/activity/streams"
- "github.com/superseriousbusiness/activity/streams/vocab"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
@@ -161,78 +158,10 @@ func (d *deref) dereferenceStatusable(ctx context.Context, tsport transport.Tran
b, err := tsport.Dereference(ctx, remoteStatusID)
if err != nil {
- return nil, fmt.Errorf("DereferenceStatusable: error deferencing %s: %s", remoteStatusID.String(), err)
+ return nil, fmt.Errorf("dereferenceStatusable: error deferencing %s: %w", remoteStatusID.String(), err)
}
- m := make(map[string]interface{})
- if err := json.Unmarshal(b, &m); err != nil {
- return nil, fmt.Errorf("DereferenceStatusable: error unmarshalling bytes into json: %s", err)
- }
-
- t, err := streams.ToType(ctx, m)
- if err != nil {
- return nil, fmt.Errorf("DereferenceStatusable: error resolving json into ap vocab type: %s", err)
- }
-
- // Article, Document, Image, Video, Note, Page, Event, Place, Mention, Profile
- switch t.GetTypeName() {
- case ap.ObjectArticle:
- p, ok := t.(vocab.ActivityStreamsArticle)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsArticle")
- }
- return p, nil
- case ap.ObjectDocument:
- p, ok := t.(vocab.ActivityStreamsDocument)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsDocument")
- }
- return p, nil
- case ap.ObjectImage:
- p, ok := t.(vocab.ActivityStreamsImage)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsImage")
- }
- return p, nil
- case ap.ObjectVideo:
- p, ok := t.(vocab.ActivityStreamsVideo)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsVideo")
- }
- return p, nil
- case ap.ObjectNote:
- p, ok := t.(vocab.ActivityStreamsNote)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsNote")
- }
- return p, nil
- case ap.ObjectPage:
- p, ok := t.(vocab.ActivityStreamsPage)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsPage")
- }
- return p, nil
- case ap.ObjectEvent:
- p, ok := t.(vocab.ActivityStreamsEvent)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsEvent")
- }
- return p, nil
- case ap.ObjectPlace:
- p, ok := t.(vocab.ActivityStreamsPlace)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsPlace")
- }
- return p, nil
- case ap.ObjectProfile:
- p, ok := t.(vocab.ActivityStreamsProfile)
- if !ok {
- return nil, errors.New("DereferenceStatusable: error resolving type as ActivityStreamsProfile")
- }
- return p, nil
- }
-
- return nil, newErrWrongType(fmt.Errorf("DereferenceStatusable: type name %s not supported as Statusable", t.GetTypeName()))
+ return ap.ResolveStatusable(ctx, b)
}
// populateStatusFields fetches all the information we temporarily pinned to an incoming