Remove unnecessary error handling for invites

This commit is contained in:
Devon Hudson 2023-07-04 21:27:38 -06:00
parent 29759ea4db
commit 05e5837800
No known key found for this signature in database
GPG key ID: CD06B18E77F6A628

View file

@ -42,20 +42,12 @@ func InviteV3(
) util.JSONResponse { ) util.JSONResponse {
inviteReq := fclient.InviteV3Request{} inviteReq := fclient.InviteV3Request{}
err := json.Unmarshal(request.Content(), &inviteReq) err := json.Unmarshal(request.Content(), &inviteReq)
switch e := err.(type) { if err != nil {
case gomatrixserverlib.UnsupportedRoomVersionError:
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: spec.UnsupportedRoomVersion(
fmt.Sprintf("Room version %q is not supported by this server.", e.Version),
),
}
case gomatrixserverlib.BadJSONError:
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: spec.BadJSON(err.Error()), JSON: spec.BadJSON(err.Error()),
} }
case nil: }
if !cfg.Matrix.IsLocalServerName(invitedUser.Domain()) { if !cfg.Matrix.IsLocalServerName(invitedUser.Domain()) {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
@ -103,12 +95,6 @@ func InviteV3(
Code: http.StatusOK, Code: http.StatusOK,
JSON: fclient.RespInviteV2{Event: event.JSON()}, JSON: fclient.RespInviteV2{Event: event.JSON()},
} }
default:
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: spec.NotJSON("The request body could not be decoded into an invite request. " + err.Error()),
}
}
} }
// InviteV2 implements /_matrix/federation/v2/invite/{roomID}/{eventID} // InviteV2 implements /_matrix/federation/v2/invite/{roomID}/{eventID}