aboutsummaryrefslogtreecommitdiff
path: root/federationapi
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-04-28 17:46:01 +0200
committerGitHub <noreply@github.com>2023-04-28 17:46:01 +0200
commit6b47cf0f6ac9176b7e5a5bd6f357722ee0f5e384 (patch)
tree484c0133034ec1968e66d69b58c4f90486b1c5ae /federationapi
parent1432743d1ad669718e8f70f4dc1f29a9762e3fc4 (diff)
Remove `PerformError` (#3066)
This removes `PerformError`, which was needed when we still had polylith. This removes quite a bunch of ```go if err != nil { return err } if err := res.Error; err != nil { return err.JSONResponse() } ``` Hopefully can be read commit by commit. [skip ci]
Diffstat (limited to 'federationapi')
-rw-r--r--federationapi/routing/invite.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go
index a4ebeaed..6fa37f4a 100644
--- a/federationapi/routing/invite.go
+++ b/federationapi/routing/invite.go
@@ -20,6 +20,7 @@ import (
"fmt"
"net/http"
+ "github.com/getsentry/sentry-go"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/types"
@@ -205,17 +206,36 @@ func processInvite(
SendAsServer: string(api.DoNotSendToOtherServers),
TransactionID: nil,
}
- response := &api.PerformInviteResponse{}
- if err := rsAPI.PerformInvite(ctx, request, response); err != nil {
+
+ if err = rsAPI.PerformInvite(ctx, request); err != nil {
util.GetLogger(ctx).WithError(err).Error("PerformInvite failed")
return util.JSONResponse{
Code: http.StatusInternalServerError,
JSON: jsonerror.InternalServerError(),
}
}
- if response.Error != nil {
- return response.Error.JSONResponse()
+
+ switch e := err.(type) {
+ case api.ErrInvalidID:
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.Unknown(e.Error()),
+ }
+ case api.ErrNotAllowed:
+ return util.JSONResponse{
+ Code: http.StatusForbidden,
+ JSON: jsonerror.Forbidden(e.Error()),
+ }
+ case nil:
+ default:
+ util.GetLogger(ctx).WithError(err).Error("PerformInvite failed")
+ sentry.CaptureException(err)
+ return util.JSONResponse{
+ Code: http.StatusInternalServerError,
+ JSON: jsonerror.InternalServerError(),
+ }
}
+
// Return the signed event to the originating server, it should then tell
// the other servers in the room that we have been invited.
if isInviteV2 {