mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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:
@@ -19,13 +19,13 @@ package dereferencing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"codeberg.org/gruf/go-kv"
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/uris"
|
||||
@@ -39,12 +39,12 @@ const maxIter = 1000
|
||||
func (d *deref) dereferenceThread(ctx context.Context, username string, statusIRI *url.URL, status *gtsmodel.Status, statusable ap.Statusable) {
|
||||
// Ensure that ancestors have been fully dereferenced
|
||||
if err := d.dereferenceStatusAncestors(ctx, username, status); err != nil {
|
||||
log.Errorf(ctx, "error dereferencing status ancestors: %v", err)
|
||||
log.Error(ctx, err) // log entry and error will include caller prefixes
|
||||
}
|
||||
|
||||
// Ensure that descendants have been fully dereferenced
|
||||
if err := d.dereferenceStatusDescendants(ctx, username, statusIRI, statusable); err != nil {
|
||||
log.Errorf(ctx, "error dereferencing status descendants: %v", err)
|
||||
log.Error(ctx, err) // log entry and error will include caller prefixes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (d *deref) dereferenceStatusAncestors(ctx context.Context, username string,
|
||||
// Parse this status's replied IRI
|
||||
replyIRI, err := url.Parse(status.InReplyToURI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid status InReplyToURI %q: %w", status.InReplyToURI, err)
|
||||
return gtserror.Newf("invalid status InReplyToURI %q: %w", status.InReplyToURI, err)
|
||||
}
|
||||
|
||||
if replyIRI.Host == config.GetHost() {
|
||||
@@ -81,13 +81,13 @@ func (d *deref) dereferenceStatusAncestors(ctx context.Context, username string,
|
||||
// This is our status, extract ID from path
|
||||
_, id, err := uris.ParseStatusesPath(replyIRI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid local status IRI %q: %w", status.InReplyToURI, err)
|
||||
return gtserror.Newf("invalid local status IRI %q: %w", status.InReplyToURI, err)
|
||||
}
|
||||
|
||||
// Fetch this status from the database
|
||||
localStatus, err := d.state.DB.GetStatusByID(ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error fetching local status %q: %w", id, err)
|
||||
return gtserror.Newf("error fetching local status %q: %w", id, err)
|
||||
}
|
||||
|
||||
// Set the fetched status
|
||||
@@ -102,7 +102,7 @@ func (d *deref) dereferenceStatusAncestors(ctx context.Context, username string,
|
||||
replyIRI,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error fetching remote status %q: %w", status.InReplyToURI, err)
|
||||
return gtserror.Newf("error fetching remote status %q: %w", status.InReplyToURI, err)
|
||||
}
|
||||
|
||||
// Set the fetched status
|
||||
@@ -110,7 +110,7 @@ func (d *deref) dereferenceStatusAncestors(ctx context.Context, username string,
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("reached %d ancestor iterations for %q", maxIter, ogIRI)
|
||||
return gtserror.Newf("reached %d ancestor iterations for %q", maxIter, ogIRI)
|
||||
}
|
||||
|
||||
func (d *deref) dereferenceStatusDescendants(ctx context.Context, username string, statusIRI *url.URL, parent ap.Statusable) error {
|
||||
@@ -312,5 +312,5 @@ stackLoop:
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("reached %d descendant iterations for %q", maxIter, ogIRI.String())
|
||||
return gtserror.Newf("reached %d descendant iterations for %q", maxIter, ogIRI.String())
|
||||
}
|
||||
|
Reference in New Issue
Block a user