[chore] improved federatingdb logging in cases of unknown iri / types (#3313)

* improved federatingdb logging in cases of unknown iri / types, add new log methods

* whoops; forgot to wrap log argument in serialize{} !

* use debug instead of warn level

* switch last entry to Debug
This commit is contained in:
kim
2024-09-17 19:35:47 +00:00
committed by GitHub
parent e337aa83b8
commit 8effc77788
13 changed files with 146 additions and 135 deletions

View File

@@ -22,7 +22,6 @@ import (
"errors"
"time"
"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"
@@ -35,15 +34,7 @@ import (
)
func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsReject) error {
if log.Level() >= level.DEBUG {
i, err := marshalItem(reject)
if err != nil {
return err
}
l := log.WithContext(ctx).
WithField("reject", i)
l.Debug("entering Reject")
}
log.DebugKV(ctx, "reject", serialize{reject})
activityContext := getActivityContext(ctx)
if activityContext.internal {
@@ -62,10 +53,8 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
for _, object := range ap.ExtractObjects(reject) {
if asType := object.GetType(); asType != nil {
// Check and handle any
// vocab.Type objects.
// nolint:gocritic
switch asType.GetTypeName() {
// Check and handle any vocab.Type objects.
switch name := asType.GetTypeName(); name {
// REJECT FOLLOW
case ap.ActivityFollow:
@@ -77,6 +66,10 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
); err != nil {
return err
}
// UNHANDLED
default:
log.Debugf(ctx, "unhandled object type: %s", name)
}
} else if object.IsIRI() {
@@ -118,6 +111,10 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
); err != nil {
return err
}
// UNHANDLED
default:
log.Debugf(ctx, "unhandled iri type: %s", objIRI)
}
}
}