Allow SyTest's 30createroom test to pass

Dendrite was requiring "preset" as a parameter to createroom when it's
not a required field.
This commit is contained in:
Andrew Morgan 2018-05-24 13:50:50 +01:00
parent ed388a32b7
commit f5e94f0e95

View file

@ -87,13 +87,17 @@ func (r createRoomRequest) Validate() *util.JSONResponse {
}
}
}
switch r.Preset {
case presetPrivateChat, presetTrustedPrivateChat, presetPublicChat:
break
default:
return &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON("preset must be any of 'private_chat', 'trusted_private_chat', 'public_chat'"),
// If set, ensure r.Preset is one of allowed types
if r.Preset != "" {
switch r.Preset {
case presetPrivateChat, presetTrustedPrivateChat, presetPublicChat:
break
default:
return &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON("preset must be any of 'private_chat', 'trusted_private_chat', 'public_chat'"),
}
}
}