From 04c95ed6f0e05ee1da0bb45fee24d36c06366a74 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 24 May 2018 13:50:50 +0100 Subject: [PATCH] Allow SyTest's 30createroom test to pass Dendrite was requiring "preset" as a parameter to createroom when it's not a required field. --- .../dendrite/clientapi/routing/createroom.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 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 05751f23..474ad33a 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go @@ -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'"), + } } }