mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 13:37:30 -06:00
[chore] Refactor federatingDB.Undo, avoid 500 errors on Undo Like (#3310)
This commit is contained in:
parent
71261c62c2
commit
0567b319c6
3 changed files with 197 additions and 90 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue