mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-30 15:02:27 -05:00
[bugfix] 2643 bug search for account url doesnt always work when redirected (#2673)
* update activity library so dereferencer returns full response and checks *final* link to allow for redirects * temporarily add bodged fixed library * remove unused code * update getAccountFeatured() to use dereferenceCollectionPage() * make sure to release map * perform a 2nd decode to ensure reader is empty after primary decode * add comment explaining choice of using Decode() instead of Unmarshal() * update embedded activity library to latest matching https://github.com/superseriousbusiness/activity/pull/21 * add checks to look for changed URI and re-check database if redirected * update max iteration count to 512, add checks during dereferenceAncestors() for indirect URLs * remove doubled-up code * fix use of status instead of current * use URIs for checking equality for security * use the latest known URI for boost_of_uri in case original was an indirect * add dereferenceCollection() function for dereferenceAccountFeatured() * pull in latest github.com/superseriousbusiness/activity version (and remove the bodge!!) * fix typo in code comments * update decodeType() to accept a readcloser and handle body closing * switch to checking using BoostOfID and add note why not using BoostOfURI * ensure InReplyTo gets unset when deleting status parent in case currently stubbed * add tests for Collection and CollectionPage iterators
This commit is contained in:
parent
37a39b98ce
commit
1d51e3c8d6
25 changed files with 814 additions and 282 deletions
21
vendor/github.com/superseriousbusiness/activity/pub/transport.go
generated
vendored
21
vendor/github.com/superseriousbusiness/activity/pub/transport.go
generated
vendored
|
|
@ -5,7 +5,6 @@ import (
|
|||
"context"
|
||||
"crypto"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
|
@ -40,11 +39,13 @@ func isSuccess(code int) bool {
|
|||
//
|
||||
// It may be reused multiple times, but never concurrently.
|
||||
type Transport interface {
|
||||
// Dereference fetches the ActivityStreams object located at this IRI
|
||||
// with a GET request.
|
||||
Dereference(c context.Context, iri *url.URL) ([]byte, error)
|
||||
// Dereference fetches the ActivityStreams object located at this IRI with
|
||||
// a GET request. Note that Response will only be returned on status = OK.
|
||||
Dereference(c context.Context, iri *url.URL) (*http.Response, error)
|
||||
|
||||
// Deliver sends an ActivityStreams object.
|
||||
Deliver(c context.Context, b []byte, to *url.URL) error
|
||||
|
||||
// BatchDeliver sends an ActivityStreams object to multiple recipients.
|
||||
BatchDeliver(c context.Context, b []byte, recipients []*url.URL) error
|
||||
}
|
||||
|
|
@ -107,9 +108,8 @@ func NewHttpSigTransport(
|
|||
}
|
||||
}
|
||||
|
||||
// Dereference sends a GET request signed with an HTTP Signature to obtain an
|
||||
// ActivityStreams value.
|
||||
func (h HttpSigTransport) Dereference(c context.Context, iri *url.URL) ([]byte, error) {
|
||||
// Dereference sends a GET request signed with an HTTP Signature to obtain an ActivityStreams value.
|
||||
func (h HttpSigTransport) Dereference(c context.Context, iri *url.URL) (*http.Response, error) {
|
||||
req, err := http.NewRequest("GET", iri.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -130,11 +130,11 @@ func (h HttpSigTransport) Dereference(c context.Context, iri *url.URL) ([]byte,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
_ = resp.Body.Close()
|
||||
return nil, fmt.Errorf("GET request to %s failed (%d): %s", iri.String(), resp.StatusCode, resp.Status)
|
||||
}
|
||||
return ioutil.ReadAll(resp.Body)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Deliver sends a POST request with an HTTP Signature.
|
||||
|
|
@ -166,8 +166,7 @@ func (h HttpSigTransport) Deliver(c context.Context, b []byte, to *url.URL) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
// BatchDeliver sends concurrent POST requests. Returns an error if any of the
|
||||
// requests had an error.
|
||||
// BatchDeliver sends concurrent POST requests. Returns an error if any of the requests had an error.
|
||||
func (h HttpSigTransport) BatchDeliver(c context.Context, b []byte, recipients []*url.URL) error {
|
||||
var wg sync.WaitGroup
|
||||
errCh := make(chan error, len(recipients))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue