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
main
Andrew Morgan 2018-07-06 02:20:17 -07:00 committed by GitHub
parent 7736e247b7
commit 7f7ae65098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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