From 7f7ae650988aaa1252858dc5e7a2366383bf00d2 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Fri, 6 Jul 2018 02:20:17 -0700 Subject: [PATCH] Don't require preset to create room (#496) * Don't require preset to create room * Set defaults if no preset. Use switch instead of if * Add default case and comment to r.Preset switch --- .../matrix-org/dendrite/clientapi/routing/createroom.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go b/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go index e5e52016..7b32ca50 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go @@ -88,8 +88,7 @@ func (r createRoomRequest) Validate() *util.JSONResponse { } } switch r.Preset { - case presetPrivateChat, presetTrustedPrivateChat, presetPublicChat: - break + case presetPrivateChat, presetTrustedPrivateChat, presetPublicChat, "": default: return &util.JSONResponse{ Code: http.StatusBadRequest, @@ -181,6 +180,11 @@ func createRoom(req *http.Request, device *authtypes.Device, case presetPublicChat: joinRules = joinRulePublic historyVisibility = historyVisibilityShared + default: + // Default room rules, r.Preset was previously checked for valid values so + // only a request with no preset should end up here. + joinRules = joinRuleInvite + historyVisibility = historyVisibilityShared } var builtEvents []gomatrixserverlib.Event