summaryrefslogtreecommitdiff
path: root/internal/federation/federatingactor.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-09-16 17:49:40 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-16 15:49:40 +0000
commit0567b319c6de0cc964bcf0b2891bdd58e887bf68 (patch)
tree490a2ea391696161f25d4622adcaef2c99353edf /internal/federation/federatingactor.go
parent[chore] Reject replies to rejected replies (#3291) (diff)
downloadgotosocial-0567b319c6de0cc964bcf0b2891bdd58e887bf68.tar.xz
[chore] Refactor federatingDB.Undo, avoid 500 errors on Undo Like (#3310)
Diffstat (limited to 'internal/federation/federatingactor.go')
-rw-r--r--internal/federation/federatingactor.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/internal/federation/federatingactor.go b/internal/federation/federatingactor.go
index b9b2c8001..d19c97c3e 100644
--- a/internal/federation/federatingactor.go
+++ b/internal/federation/federatingactor.go
@@ -168,16 +168,24 @@ func (f *federatingActor) PostInboxScheme(ctx context.Context, w http.ResponseWr
// the POST request is authentic (properly signed) and authorized
// (permitted to interact with the target inbox).
//
- // Post the activity to the Actor's inbox and trigger side effects .
+ // Post the activity to the Actor's inbox and trigger side effects.
if err := f.sideEffectActor.PostInbox(ctx, inboxID, activity); err != nil {
- // Special case: We know it is a bad request if the object or target
- // props needed to be populated, or we failed parsing activity details.
- // Send the rejection to the peer.
- if errors.Is(err, pub.ErrObjectRequired) ||
- errors.Is(err, pub.ErrTargetRequired) ||
- gtserror.IsMalformed(err) {
+ // Check if a function in the federatingDB
+ // has returned an explicit errWithCode for us.
+ if errWithCode, ok := err.(gtserror.WithCode); ok {
+ return false, errWithCode
+ }
+
+ // Check if it's a bad request because the
+ // object or target props weren't populated,
+ // or we failed parsing activity details.
+ //
+ // Log such activities to help debug, then
+ // return the rejection (400) to the peer.
+ if gtserror.IsMalformed(err) ||
+ errors.Is(err, pub.ErrObjectRequired) ||
+ errors.Is(err, pub.ErrTargetRequired) {
- // Log malformed activities to help debug.
l = l.WithField("activity", activity)
l.Warnf("malformed incoming activity: %v", err)
@@ -185,7 +193,7 @@ func (f *federatingActor) PostInboxScheme(ctx context.Context, w http.ResponseWr
return false, gtserror.NewErrorBadRequest(errors.New(text), text)
}
- // There's been some real error.
+ // Default: there's been some real error.
err := gtserror.Newf("error calling sideEffectActor.PostInbox: %w", err)
return false, gtserror.NewErrorInternalError(err)
}