mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-10 23:53:09 -06:00
Remove unnecessary error handling for invites
This commit is contained in:
parent
29759ea4db
commit
05e5837800
|
|
@ -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}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue