diff options
Diffstat (limited to 'internal/federation/federatingdb')
| -rw-r--r-- | internal/federation/federatingdb/accept.go | 13 | ||||
| -rw-r--r-- | internal/federation/federatingdb/announce.go | 13 | ||||
| -rw-r--r-- | internal/federation/federatingdb/create.go | 23 | ||||
| -rw-r--r-- | internal/federation/federatingdb/delete.go | 13 | ||||
| -rw-r--r-- | internal/federation/federatingdb/exists.go | 12 | ||||
| -rw-r--r-- | internal/federation/federatingdb/followers.go | 12 | ||||
| -rw-r--r-- | internal/federation/federatingdb/following.go | 12 | ||||
| -rw-r--r-- | internal/federation/federatingdb/get.go | 12 | ||||
| -rw-r--r-- | internal/federation/federatingdb/owns.go | 12 | ||||
| -rw-r--r-- | internal/federation/federatingdb/reject.go | 13 | ||||
| -rw-r--r-- | internal/federation/federatingdb/undo.go | 11 | ||||
| -rw-r--r-- | internal/federation/federatingdb/update.go | 11 | ||||
| -rw-r--r-- | internal/federation/federatingdb/util.go | 17 | 
13 files changed, 66 insertions, 108 deletions
| diff --git a/internal/federation/federatingdb/accept.go b/internal/federation/federatingdb/accept.go index f22db38a5..977cf2bba 100644 --- a/internal/federation/federatingdb/accept.go +++ b/internal/federation/federatingdb/accept.go @@ -23,28 +23,23 @@ import (  	"errors"  	"fmt" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap"  	"github.com/superseriousbusiness/gotosocial/internal/db"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/messages"  	"github.com/superseriousbusiness/gotosocial/internal/uris"  )  func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsAccept) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Accept", -		}, -	) - -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(accept)  		if err != nil {  			return err  		} -		l = l.WithField("accept", i) +		l := log.WithField("accept", i)  		l.Debug("entering Accept")  	} diff --git a/internal/federation/federatingdb/announce.go b/internal/federation/federatingdb/announce.go index b70fa1913..47e873ca3 100644 --- a/internal/federation/federatingdb/announce.go +++ b/internal/federation/federatingdb/announce.go @@ -22,25 +22,20 @@ import (  	"context"  	"fmt" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/messages"  )  func (f *federatingDB) Announce(ctx context.Context, announce vocab.ActivityStreamsAnnounce) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Announce", -		}, -	) - -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(announce)  		if err != nil {  			return err  		} -		l = l.WithField("announce", i) +		l := log.WithField("announce", i)  		l.Debug("entering Announce")  	} diff --git a/internal/federation/federatingdb/create.go b/internal/federation/federatingdb/create.go index 625d75603..a6e55f2ad 100644 --- a/internal/federation/federatingdb/create.go +++ b/internal/federation/federatingdb/create.go @@ -24,12 +24,14 @@ import (  	"fmt"  	"strings" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap"  	"github.com/superseriousbusiness/gotosocial/internal/db"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"  	"github.com/superseriousbusiness/gotosocial/internal/id" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/messages"  ) @@ -46,18 +48,12 @@ import (  // Under certain conditions and network activities, Create may be called  // multiple times for the same ActivityStreams object.  func (f *federatingDB) Create(ctx context.Context, asType vocab.Type) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Create", -		}, -	) - -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(asType)  		if err != nil {  			return err  		} -		l = l.WithField("create", i) +		l := log.WithField("create", i)  		l.Debug("entering Create")  	} @@ -169,11 +165,10 @@ func (f *federatingDB) activityCreate(ctx context.Context, asType vocab.Type, re  // createNote handles a Create activity with a Note type.  func (f *federatingDB) createNote(ctx context.Context, note vocab.ActivityStreamsNote, receivingAccount *gtsmodel.Account, requestingAccount *gtsmodel.Account) error { -	l := logrus.WithFields(logrus.Fields{ -		"func":              "createNote", -		"receivingAccount":  receivingAccount.URI, -		"requestingAccount": requestingAccount.URI, -	}) +	l := log.WithFields(kv.Fields{ +		{"receivingAccount", receivingAccount.URI}, +		{"requestingAccount", requestingAccount.URI}, +	}...)  	// Check if we have a forward.  	// In other words, was the note posted to our inbox by at least one actor who actually created the note, or are they just forwarding it? diff --git a/internal/federation/federatingdb/delete.go b/internal/federation/federatingdb/delete.go index bd0184f76..8c3457fae 100644 --- a/internal/federation/federatingdb/delete.go +++ b/internal/federation/federatingdb/delete.go @@ -23,9 +23,10 @@ import (  	"fmt"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv"  	"github.com/superseriousbusiness/gotosocial/internal/ap"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/messages"  ) @@ -36,12 +37,10 @@ import (  //  // The library makes this call only after acquiring a lock first.  func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Delete", -			"id":   id, -		}, -	) +	l := log.WithFields(kv.Fields{ + +		{"id", id}, +	}...)  	l.Debug("entering Delete")  	receivingAccount, _ := extractFromCtx(ctx) diff --git a/internal/federation/federatingdb/exists.go b/internal/federation/federatingdb/exists.go index fe220fc71..65b2a55b3 100644 --- a/internal/federation/federatingdb/exists.go +++ b/internal/federation/federatingdb/exists.go @@ -22,7 +22,8 @@ import (  	"context"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv" +	"github.com/superseriousbusiness/gotosocial/internal/log"  )  // Exists returns true if the database has an entry for the specified @@ -32,12 +33,9 @@ import (  //  // Implementation note: this just straight up isn't implemented, and doesn't *really* need to be either.  func (f *federatingDB) Exists(c context.Context, id *url.URL) (exists bool, err error) { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Exists", -			"id":   id, -		}, -	) +	l := log.WithFields(kv.Fields{ +		{"id", id}, +	}...)  	l.Debug("entering Exists")  	return false, nil  } diff --git a/internal/federation/federatingdb/followers.go b/internal/federation/federatingdb/followers.go index 96b824c66..9a80d5f0b 100644 --- a/internal/federation/federatingdb/followers.go +++ b/internal/federation/federatingdb/followers.go @@ -5,9 +5,10 @@ import (  	"fmt"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/db" +	"github.com/superseriousbusiness/gotosocial/internal/log"  )  // Followers obtains the Followers Collection for an actor with the @@ -17,12 +18,9 @@ import (  //  // The library makes this call only after acquiring a lock first.  func (f *federatingDB) Followers(ctx context.Context, actorIRI *url.URL) (followers vocab.ActivityStreamsCollection, err error) { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Followers", -			"id":   actorIRI, -		}, -	) +	l := log.WithFields(kv.Fields{ +		{"id", actorIRI}, +	}...)  	l.Debug("entering Followers")  	acct, err := f.getAccountForIRI(ctx, actorIRI) diff --git a/internal/federation/federatingdb/following.go b/internal/federation/federatingdb/following.go index 62b148d5b..a244cf7ac 100644 --- a/internal/federation/federatingdb/following.go +++ b/internal/federation/federatingdb/following.go @@ -23,9 +23,10 @@ import (  	"fmt"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/db" +	"github.com/superseriousbusiness/gotosocial/internal/log"  )  // Following obtains the Following Collection for an actor with the @@ -35,12 +36,9 @@ import (  //  // The library makes this call only after acquiring a lock first.  func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (following vocab.ActivityStreamsCollection, err error) { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Following", -			"id":   actorIRI, -		}, -	) +	l := log.WithFields(kv.Fields{ +		{"id", actorIRI}, +	}...)  	l.Debug("entering Following")  	acct, err := f.getAccountForIRI(ctx, actorIRI) diff --git a/internal/federation/federatingdb/get.go b/internal/federation/federatingdb/get.go index 9fdc08dd9..5467c886d 100644 --- a/internal/federation/federatingdb/get.go +++ b/internal/federation/federatingdb/get.go @@ -23,8 +23,9 @@ import (  	"errors"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv"  	"github.com/superseriousbusiness/activity/streams/vocab" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/uris"  ) @@ -32,12 +33,9 @@ import (  //  // The library makes this call only after acquiring a lock first.  func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type, err error) { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Get", -			"id":   id, -		}, -	) +	l := log.WithFields(kv.Fields{ +		{"id", id}, +	}...)  	l.Debug("entering Get")  	if uris.IsUserPath(id) { diff --git a/internal/federation/federatingdb/owns.go b/internal/federation/federatingdb/owns.go index aaa58348f..51d11f018 100644 --- a/internal/federation/federatingdb/owns.go +++ b/internal/federation/federatingdb/owns.go @@ -23,10 +23,11 @@ import (  	"fmt"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-kv"  	"github.com/superseriousbusiness/gotosocial/internal/config"  	"github.com/superseriousbusiness/gotosocial/internal/db"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/uris"  ) @@ -34,12 +35,9 @@ import (  // the database has an entry for the IRI.  // The library makes this call only after acquiring a lock first.  func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Owns", -			"id":   id, -		}, -	) +	l := log.WithFields(kv.Fields{ +		{"id", id}, +	}...)  	l.Debug("entering Owns")  	// if the id host isn't this instance host, we don't own this IRI diff --git a/internal/federation/federatingdb/reject.go b/internal/federation/federatingdb/reject.go index 9cb81c267..b77c3ce3a 100644 --- a/internal/federation/federatingdb/reject.go +++ b/internal/federation/federatingdb/reject.go @@ -23,27 +23,22 @@ import (  	"errors"  	"fmt" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap"  	"github.com/superseriousbusiness/gotosocial/internal/db"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/uris"  )  func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsReject) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Reject", -		}, -	) - -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(reject)  		if err != nil {  			return err  		} -		l = l.WithField("reject", i) +		l := log.WithField("reject", i)  		l.Debug("entering Reject")  	} diff --git a/internal/federation/federatingdb/undo.go b/internal/federation/federatingdb/undo.go index 92f24f315..4cb3d0fa8 100644 --- a/internal/federation/federatingdb/undo.go +++ b/internal/federation/federatingdb/undo.go @@ -23,21 +23,18 @@ import (  	"errors"  	"fmt" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap"  	"github.com/superseriousbusiness/gotosocial/internal/db"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  )  func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Undo", -		}, -	) +	l := log.Entry{} -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(undo)  		if err != nil {  			return err diff --git a/internal/federation/federatingdb/update.go b/internal/federation/federatingdb/update.go index 09d5c8fd8..599544e34 100644 --- a/internal/federation/federatingdb/update.go +++ b/internal/federation/federatingdb/update.go @@ -23,11 +23,12 @@ import (  	"errors"  	"fmt" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap"  	"github.com/superseriousbusiness/gotosocial/internal/config"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/messages"  ) @@ -41,13 +42,9 @@ import (  //  // The library makes this call only after acquiring a lock first.  func (f *federatingDB) Update(ctx context.Context, asType vocab.Type) error { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "Update", -		}, -	) +	l := log.Entry{} -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(asType)  		if err != nil {  			return err diff --git a/internal/federation/federatingdb/util.go b/internal/federation/federatingdb/util.go index 7f27cc759..9fc35faa4 100644 --- a/internal/federation/federatingdb/util.go +++ b/internal/federation/federatingdb/util.go @@ -25,7 +25,7 @@ import (  	"fmt"  	"net/url" -	"github.com/sirupsen/logrus" +	"codeberg.org/gruf/go-logger/v2/level"  	"github.com/superseriousbusiness/activity/streams"  	"github.com/superseriousbusiness/activity/streams/vocab"  	"github.com/superseriousbusiness/gotosocial/internal/ap" @@ -33,6 +33,7 @@ import (  	"github.com/superseriousbusiness/gotosocial/internal/db"  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"  	"github.com/superseriousbusiness/gotosocial/internal/id" +	"github.com/superseriousbusiness/gotosocial/internal/log"  	"github.com/superseriousbusiness/gotosocial/internal/uris"  ) @@ -63,18 +64,12 @@ func sameActor(activityActor vocab.ActivityStreamsActorProperty, followActor voc  // The go-fed library will handle setting the 'id' property on the  // activity or object provided with the value returned.  func (f *federatingDB) NewID(ctx context.Context, t vocab.Type) (idURL *url.URL, err error) { -	l := logrus.WithFields( -		logrus.Fields{ -			"func": "NewID", -		}, -	) - -	if logrus.GetLevel() >= logrus.DebugLevel { +	if log.Level() >= level.DEBUG {  		i, err := marshalItem(t)  		if err != nil {  			return nil, err  		} -		l = l.WithField("newID", i) +		l := log.WithField("newID", i)  		l.Debug("entering NewID")  	} @@ -312,7 +307,7 @@ func extractFromCtx(ctx context.Context) (receivingAccount, requestingAccount *g  		var ok bool  		receivingAccount, ok = receivingAccountI.(*gtsmodel.Account)  		if !ok { -			logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", ap.ContextReceivingAccount) +			log.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", ap.ContextReceivingAccount)  		}  	} @@ -321,7 +316,7 @@ func extractFromCtx(ctx context.Context) (receivingAccount, requestingAccount *g  		var ok bool  		requestingAccount, ok = requestingAcctI.(*gtsmodel.Account)  		if !ok { -			logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", ap.ContextRequestingAccount) +			log.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", ap.ContextRequestingAccount)  		}  	} | 
