diff options
author | 2023-03-01 18:52:44 +0100 | |
---|---|---|
committer | 2023-03-01 17:52:44 +0000 | |
commit | 24cec4e7aab33b6c44ba6d1ecf16895f254351b8 (patch) | |
tree | cf0107a34e0fa00ab1b68aed4b52afe502147393 /internal/federation/dereferencing/status.go | |
parent | [chore/performance] simplify storage driver to use storage.Storage directly (... (diff) | |
download | gotosocial-24cec4e7aab33b6c44ba6d1ecf16895f254351b8.tar.xz |
[feature] Federate pinned posts (aka `featuredCollection`) in and out (#1560)
* start fiddling
* the ol' fiddle + update
* start working on fetching statuses
* poopy doopy doo where r u uwu
* further adventures in featuring statuses
* finishing up
* fmt
* simply status unpin loop
* move empty featured check back to caller function
* remove unnecessary log.WithContext calls
* remove unnecessary IsIRI() checks
* add explanatory comment about status URIs
* change log level to error
* better test names
Diffstat (limited to 'internal/federation/dereferencing/status.go')
-rw-r--r-- | internal/federation/dereferencing/status.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go index 56545c5e0..9242f8db2 100644 --- a/internal/federation/dereferencing/status.go +++ b/internal/federation/dereferencing/status.go @@ -35,6 +35,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/internal/transport" ) // EnrichRemoteStatus takes a remote status that's already been inserted into the database in a minimal form, @@ -105,7 +106,12 @@ func (d *deref) GetStatus(ctx context.Context, username string, statusURI *url.U // if we got here, either we didn't have the status // in the db, or we had it but need to refetch it - statusable, derefErr := d.dereferenceStatusable(ctx, username, statusURI) + tsport, err := d.transportController.NewTransportForUsername(ctx, username) + if err != nil { + return nil, nil, newErrTransportError(fmt.Errorf("GetRemoteStatus: error creating transport for %s: %w", username, err)) + } + + statusable, derefErr := d.dereferenceStatusable(ctx, tsport, statusURI) if derefErr != nil { return nil, nil, wrapDerefError(derefErr, "GetRemoteStatus: error dereferencing statusable") } @@ -149,17 +155,12 @@ func (d *deref) GetStatus(ctx context.Context, username string, statusURI *url.U return status, statusable, nil } -func (d *deref) dereferenceStatusable(ctx context.Context, username string, remoteStatusID *url.URL) (ap.Statusable, error) { +func (d *deref) dereferenceStatusable(ctx context.Context, tsport transport.Transport, remoteStatusID *url.URL) (ap.Statusable, error) { if blocked, err := d.db.IsDomainBlocked(ctx, remoteStatusID.Host); blocked || err != nil { return nil, fmt.Errorf("DereferenceStatusable: domain %s is blocked", remoteStatusID.Host) } - transport, err := d.transportController.NewTransportForUsername(ctx, username) - if err != nil { - return nil, fmt.Errorf("DereferenceStatusable: transport err: %s", err) - } - - b, err := transport.Dereference(ctx, remoteStatusID) + b, err := tsport.Dereference(ctx, remoteStatusID) if err != nil { return nil, fmt.Errorf("DereferenceStatusable: error deferencing %s: %s", remoteStatusID.String(), err) } |