mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 12:52:27 -05:00
[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:
parent
e337aa83b8
commit
8effc77788
13 changed files with 146 additions and 135 deletions
|
|
@ -22,7 +22,6 @@ import (
|
|||
"errors"
|
||||
"net/url"
|
||||
|
||||
"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"
|
||||
|
|
@ -46,15 +45,7 @@ func (f *federatingDB) GetAccept(
|
|||
}
|
||||
|
||||
func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsAccept) error {
|
||||
if log.Level() >= level.DEBUG {
|
||||
i, err := marshalItem(accept)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l := log.WithContext(ctx).
|
||||
WithField("accept", i)
|
||||
l.Debug("entering Accept")
|
||||
}
|
||||
log.DebugKV(ctx, "accept", serialize{accept})
|
||||
|
||||
activityContext := getActivityContext(ctx)
|
||||
if activityContext.internal {
|
||||
|
|
@ -81,10 +72,9 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
|
|||
// handling the ones we know how to handle.
|
||||
for _, object := range ap.ExtractObjects(accept) {
|
||||
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 {
|
||||
|
||||
// ACCEPT FOLLOW
|
||||
case ap.ActivityFollow:
|
||||
|
|
@ -96,6 +86,10 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
|
|||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// UNHANDLED
|
||||
default:
|
||||
log.Debugf(ctx, "unhandled object type: %s", name)
|
||||
}
|
||||
|
||||
} else if object.IsIRI() {
|
||||
|
|
@ -137,6 +131,10 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
|
|||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// UNHANDLED
|
||||
default:
|
||||
log.Debugf(ctx, "unhandled iri type: %s", objIRI)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue