[chore] tidy up media manager, add calling func to errors, build-script improvements (#1835)

* media manager tidy-up: de-interface and remove unused PostDataFunc

Signed-off-by: kim <grufwub@gmail.com>

* remove last traces of media.Manager being an interface

Signed-off-by: kim <grufwub@gmail.com>

* update error to provide caller, allow tuneable via build tags

Signed-off-by: kim <grufwub@gmail.com>

* remove kim-specific build script changes

Signed-off-by: kim <grufwub@gmail.com>

* fix merge conflicts

Signed-off-by: kim <grufwub@gmail.com>

* update build-script to support externally setting build variables

Signed-off-by: kim <grufwub@gmail.com>

---------

Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
kim 2023-05-28 13:08:35 +01:00 committed by GitHub
commit 5faeb4de20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 444 additions and 392 deletions

View file

@ -130,7 +130,7 @@ func (t *transport) deliver(ctx context.Context, b []byte, to *url.URL) error {
if code := rsp.StatusCode; code != http.StatusOK &&
code != http.StatusCreated && code != http.StatusAccepted {
return gtserror.NewResponseError(rsp)
return gtserror.NewFromResponse(rsp)
}
return nil

View file

@ -65,7 +65,7 @@ func (t *transport) Dereference(ctx context.Context, iri *url.URL) ([]byte, erro
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return nil, gtserror.NewResponseError(rsp)
return nil, gtserror.NewFromResponse(rsp)
}
return io.ReadAll(rsp.Body)

View file

@ -102,7 +102,7 @@ func dereferenceByAPIV1Instance(ctx context.Context, t *transport, iri *url.URL)
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, gtserror.NewResponseError(resp)
return nil, gtserror.NewFromResponse(resp)
}
b, err := io.ReadAll(resp.Body)
@ -252,7 +252,7 @@ func callNodeInfoWellKnown(ctx context.Context, t *transport, iri *url.URL) (*ur
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, gtserror.NewResponseError(resp)
return nil, gtserror.NewFromResponse(resp)
}
b, err := io.ReadAll(resp.Body)
@ -303,7 +303,7 @@ func callNodeInfo(ctx context.Context, t *transport, iri *url.URL) (*apimodel.No
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, gtserror.NewResponseError(resp)
return nil, gtserror.NewFromResponse(resp)
}
b, err := io.ReadAll(resp.Body)

View file

@ -46,7 +46,7 @@ func (t *transport) DereferenceMedia(ctx context.Context, iri *url.URL) (io.Read
// Check for an expected status code
if rsp.StatusCode != http.StatusOK {
return nil, 0, gtserror.NewResponseError(rsp)
return nil, 0, gtserror.NewFromResponse(rsp)
}
return rsp.Body, rsp.ContentLength, nil

View file

@ -156,7 +156,7 @@ func (t *transport) Finger(ctx context.Context, targetUsername string, targetDom
}
// We've reached the end of the line here, both the original request
// and our attempt to resolve it through the fallback have failed
return nil, gtserror.NewResponseError(rsp)
return nil, gtserror.NewFromResponse(rsp)
}
// Set the URL in cache here, since host-meta told us this should be the

View file

@ -39,7 +39,7 @@ type TransportTestSuite struct {
suite.Suite
db db.DB
storage *storage.Driver
mediaManager media.Manager
mediaManager *media.Manager
federator federation.Federator
processor *processing.Processor
emailSender email.Sender