mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 09:53:10 -06:00
Set defaults if no preset. Use switch instead of if
This commit is contained in:
parent
7d246f906a
commit
f1e1e39499
|
|
@ -87,17 +87,14 @@ func (r createRoomRequest) Validate() *util.JSONResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if r.Preset != "" {
|
|
||||||
switch r.Preset {
|
switch r.Preset {
|
||||||
case presetPrivateChat, presetTrustedPrivateChat, presetPublicChat:
|
case presetPrivateChat, presetTrustedPrivateChat, presetPublicChat, "":
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
return &util.JSONResponse{
|
return &util.JSONResponse{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
JSON: jsonerror.BadJSON("preset must be any of 'private_chat', 'trusted_private_chat', 'public_chat'"),
|
JSON: jsonerror.BadJSON("preset must be any of 'private_chat', 'trusted_private_chat', 'public_chat'"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +169,7 @@ func createRoom(req *http.Request, device *authtypes.Device,
|
||||||
|
|
||||||
var joinRules, historyVisibility string
|
var joinRules, historyVisibility string
|
||||||
switch r.Preset {
|
switch r.Preset {
|
||||||
case presetPrivateChat:
|
case presetPrivateChat, "":
|
||||||
joinRules = joinRuleInvite
|
joinRules = joinRuleInvite
|
||||||
historyVisibility = historyVisibilityShared
|
historyVisibility = historyVisibilityShared
|
||||||
case presetTrustedPrivateChat:
|
case presetTrustedPrivateChat:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue