diff options
Diffstat (limited to 'internal/federation/dereferencing')
-rw-r--r-- | internal/federation/dereferencing/account.go | 4 | ||||
-rw-r--r-- | internal/federation/dereferencing/attachment.go | 2 | ||||
-rw-r--r-- | internal/federation/dereferencing/dereferencer.go | 5 | ||||
-rw-r--r-- | internal/federation/dereferencing/dereferencer_test.go | 14 | ||||
-rw-r--r-- | internal/federation/dereferencing/status.go | 20 | ||||
-rw-r--r-- | internal/federation/dereferencing/thread.go | 6 |
6 files changed, 19 insertions, 32 deletions
diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go index 6acb3b06d..7d8e2ff94 100644 --- a/internal/federation/dereferencing/account.go +++ b/internal/federation/dereferencing/account.go @@ -59,7 +59,7 @@ func (d *deref) EnrichRemoteAccount(ctx context.Context, username string, accoun updated, err := d.db.UpdateAccount(ctx, account) if err != nil { - d.log.Errorf("EnrichRemoteAccount: error updating account: %s", err) + logrus.Errorf("EnrichRemoteAccount: error updating account: %s", err) return account, nil } @@ -203,7 +203,7 @@ func (d *deref) dereferenceAccountable(ctx context.Context, username string, rem // PopulateAccountFields populates any fields on the given account that weren't populated by the initial // dereferencing. This includes things like header and avatar etc. func (d *deref) PopulateAccountFields(ctx context.Context, account *gtsmodel.Account, requestingUsername string, refresh bool) error { - l := d.log.WithFields(logrus.Fields{ + l := logrus.WithFields(logrus.Fields{ "func": "PopulateAccountFields", "requestingUsername": requestingUsername, }) diff --git a/internal/federation/dereferencing/attachment.go b/internal/federation/dereferencing/attachment.go index fd0cfba18..3a4213cdb 100644 --- a/internal/federation/dereferencing/attachment.go +++ b/internal/federation/dereferencing/attachment.go @@ -34,7 +34,7 @@ func (d *deref) GetRemoteAttachment(ctx context.Context, requestingUsername stri } remoteAttachmentURL := minAttachment.RemoteURL - l := d.log.WithFields(logrus.Fields{ + l := logrus.WithFields(logrus.Fields{ "username": requestingUsername, "remoteAttachmentURL": remoteAttachmentURL, }) diff --git a/internal/federation/dereferencing/dereferencer.go b/internal/federation/dereferencing/dereferencer.go index ea347b30e..76fd830a2 100644 --- a/internal/federation/dereferencing/dereferencer.go +++ b/internal/federation/dereferencing/dereferencer.go @@ -23,7 +23,6 @@ import ( "net/url" "sync" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" @@ -79,7 +78,6 @@ type Dereferencer interface { } type deref struct { - log *logrus.Logger db db.DB typeConverter typeutils.TypeConverter transportController transport.Controller @@ -90,9 +88,8 @@ type deref struct { } // NewDereferencer returns a Dereferencer initialized with the given parameters. -func NewDereferencer(config *config.Config, db db.DB, typeConverter typeutils.TypeConverter, transportController transport.Controller, mediaHandler media.Handler, log *logrus.Logger) Dereferencer { +func NewDereferencer(config *config.Config, db db.DB, typeConverter typeutils.TypeConverter, transportController transport.Controller, mediaHandler media.Handler) Dereferencer { return &deref{ - log: log, db: db, typeConverter: typeConverter, transportController: transportController, diff --git a/internal/federation/dereferencing/dereferencer_test.go b/internal/federation/dereferencing/dereferencer_test.go index 0eeabc64a..051bf95ce 100644 --- a/internal/federation/dereferencing/dereferencer_test.go +++ b/internal/federation/dereferencing/dereferencer_test.go @@ -41,7 +41,6 @@ type DereferencerStandardTestSuite struct { suite.Suite config *config.Config db db.DB - log *logrus.Logger storage *kv.KVStore testRemoteStatuses map[string]vocab.ActivityStreamsNote @@ -64,14 +63,9 @@ func (suite *DereferencerStandardTestSuite) SetupSuite() { func (suite *DereferencerStandardTestSuite) SetupTest() { suite.config = testrig.NewTestConfig() suite.db = testrig.NewTestDB() - suite.log = testrig.NewTestLog() + testrig.InitTestLog() suite.storage = testrig.NewTestStorage() - suite.dereferencer = dereferencing.NewDereferencer(suite.config, - suite.db, - testrig.NewTestTypeConverter(suite.db), - suite.mockTransportController(), - testrig.NewTestMediaHandler(suite.db, suite.storage), - suite.log) + suite.dereferencer = dereferencing.NewDereferencer(suite.config, suite.db, testrig.NewTestTypeConverter(suite.db), suite.mockTransportController(), testrig.NewTestMediaHandler(suite.db, suite.storage)) testrig.StandardDBSetup(suite.db, nil) } @@ -85,7 +79,7 @@ func (suite *DereferencerStandardTestSuite) TearDownTest() { // or note or attachment that we have stored, then just a 200 code will be returned, with an empty body. func (suite *DereferencerStandardTestSuite) mockTransportController() transport.Controller { do := func(req *http.Request) (*http.Response, error) { - suite.log.Debugf("received request for %s", req.URL) + logrus.Debugf("received request for %s", req.URL) responseBytes := []byte{} responseType := "" @@ -140,7 +134,7 @@ func (suite *DereferencerStandardTestSuite) mockTransportController() transport. if len(responseBytes) != 0 { // we found something, so print what we're going to return - suite.log.Debugf("returning response %s", string(responseBytes)) + logrus.Debugf("returning response %s", string(responseBytes)) } responseLength = len(responseBytes) diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go index 435bc9217..c4102a8f3 100644 --- a/internal/federation/dereferencing/status.go +++ b/internal/federation/dereferencing/status.go @@ -236,7 +236,7 @@ func (d *deref) dereferenceStatusable(ctx context.Context, username string, remo // and attach them to the status. The status itself will not be added to the database yet, // that's up the caller to do. func (d *deref) populateStatusFields(ctx context.Context, status *gtsmodel.Status, requestingUsername string, includeParent bool) error { - l := d.log.WithFields(logrus.Fields{ + l := logrus.WithFields(logrus.Fields{ "func": "dereferenceStatusFields", "status": fmt.Sprintf("%+v", status), }) @@ -292,8 +292,6 @@ func (d *deref) populateStatusFields(ctx context.Context, status *gtsmodel.Statu } func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Status, requestingUsername string) error { - l := d.log - // At this point, mentions should have the namestring and mentionedAccountURI set on them. // We can use these to find the accounts. @@ -302,20 +300,20 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta for _, m := range status.Mentions { if m.ID != "" { // we've already populated this mention, since it has an ID - l.Debug("populateStatusMentions: mention already populated") + logrus.Debug("populateStatusMentions: mention already populated") mentionIDs = append(mentionIDs, m.ID) newMentions = append(newMentions, m) continue } if m.TargetAccountURI == "" { - l.Debug("populateStatusMentions: target URI not set on mention") + logrus.Debug("populateStatusMentions: target URI not set on mention") continue } targetAccountURI, err := url.Parse(m.TargetAccountURI) if err != nil { - l.Debugf("populateStatusMentions: error parsing mentioned account uri %s: %s", m.TargetAccountURI, err) + logrus.Debugf("populateStatusMentions: error parsing mentioned account uri %s: %s", m.TargetAccountURI, err) continue } @@ -326,7 +324,7 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta if a, err := d.db.GetAccountByURI(ctx, targetAccountURI.String()); err != nil { errs = append(errs, err.Error()) } else { - l.Debugf("populateStatusMentions: got target account %s with id %s through GetAccountByURI", targetAccountURI, a.ID) + logrus.Debugf("populateStatusMentions: got target account %s with id %s through GetAccountByURI", targetAccountURI, a.ID) targetAccount = a } @@ -336,13 +334,13 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta if a, _, err := d.GetRemoteAccount(ctx, requestingUsername, targetAccountURI, false); err != nil { errs = append(errs, err.Error()) } else { - l.Debugf("populateStatusMentions: got target account %s with id %s through GetRemoteAccount", targetAccountURI, a.ID) + logrus.Debugf("populateStatusMentions: got target account %s with id %s through GetRemoteAccount", targetAccountURI, a.ID) targetAccount = a } } if targetAccount == nil { - l.Debugf("populateStatusMentions: couldn't get target account %s: %s", m.TargetAccountURI, strings.Join(errs, " : ")) + logrus.Debugf("populateStatusMentions: couldn't get target account %s: %s", m.TargetAccountURI, strings.Join(errs, " : ")) continue } @@ -382,8 +380,6 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta } func (d *deref) populateStatusAttachments(ctx context.Context, status *gtsmodel.Status, requestingUsername string) error { - l := d.log - // At this point we should know: // * the media type of the file we're looking for (a.File.ContentType) // * the file type (a.Type) @@ -399,7 +395,7 @@ func (d *deref) populateStatusAttachments(ctx context.Context, status *gtsmodel. attachment, err := d.GetRemoteAttachment(ctx, requestingUsername, a) if err != nil { - l.Errorf("populateStatusAttachments: couldn't get remote attachment %s: %s", a.RemoteURL, err) + logrus.Errorf("populateStatusAttachments: couldn't get remote attachment %s: %s", a.RemoteURL, err) continue } diff --git a/internal/federation/dereferencing/thread.go b/internal/federation/dereferencing/thread.go index 87cc42918..4912bc591 100644 --- a/internal/federation/dereferencing/thread.go +++ b/internal/federation/dereferencing/thread.go @@ -35,7 +35,7 @@ import ( // presented by remote instances as part of their replies collections, and will likely involve making several calls to // multiple different hosts. func (d *deref) DereferenceThread(ctx context.Context, username string, statusIRI *url.URL) error { - l := d.log.WithFields(logrus.Fields{ + l := logrus.WithFields(logrus.Fields{ "func": "DereferenceThread", "username": username, "statusIRI": statusIRI.String(), @@ -69,7 +69,7 @@ func (d *deref) DereferenceThread(ctx context.Context, username string, statusIR // iterateAncestors has the goal of reaching the oldest ancestor of a given status, and stashing all statuses along the way. func (d *deref) iterateAncestors(ctx context.Context, username string, statusIRI url.URL) error { - l := d.log.WithFields(logrus.Fields{ + l := logrus.WithFields(logrus.Fields{ "func": "iterateAncestors", "username": username, "statusIRI": statusIRI.String(), @@ -121,7 +121,7 @@ func (d *deref) iterateAncestors(ctx context.Context, username string, statusIRI } func (d *deref) iterateDescendants(ctx context.Context, username string, statusIRI url.URL, statusable ap.Statusable) error { - l := d.log.WithFields(logrus.Fields{ + l := logrus.WithFields(logrus.Fields{ "func": "iterateDescendants", "username": username, "statusIRI": statusIRI.String(), |