diff options
Diffstat (limited to 'internal/api/activitypub/users/inboxpost.go')
-rw-r--r-- | internal/api/activitypub/users/inboxpost.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/api/activitypub/users/inboxpost.go b/internal/api/activitypub/users/inboxpost.go index 03ba5c5a6..b0a9a49ee 100644 --- a/internal/api/activitypub/users/inboxpost.go +++ b/internal/api/activitypub/users/inboxpost.go @@ -18,13 +18,14 @@ package users import ( - "errors" "net/http" "github.com/gin-gonic/gin" apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/log" + + errorsv2 "codeberg.org/gruf/go-errors/v2" ) // InboxPOSTHandler deals with incoming POST requests to an actor's inbox. @@ -32,18 +33,18 @@ import ( func (m *Module) InboxPOSTHandler(c *gin.Context) { _, err := m.processor.Fedi().InboxPost(c.Request.Context(), c.Writer, c.Request) if err != nil { - errWithCode := new(gtserror.WithCode) + errWithCode := errorsv2.AsV2[gtserror.WithCode](err) - if !errors.As(err, errWithCode) { + if errWithCode == nil { // Something else went wrong, and someone forgot to return // an errWithCode! It's chill though. Log the error but don't // return it as-is to the caller, to avoid leaking internals. log.Errorf(c.Request.Context(), "returning Bad Request to caller, err was: %q", err) - *errWithCode = gtserror.NewErrorBadRequest(err) + errWithCode = gtserror.NewErrorBadRequest(err) } // Pass along confirmed error with code to the main error handler - apiutil.ErrorHandler(c, *errWithCode, m.processor.InstanceGetV1) + apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return } |