Only unmarshal create content if specified

This commit is contained in:
Neil Alexander 2021-07-21 11:19:53 +01:00
parent f27bda2298
commit 60f43e37c2
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -207,10 +207,12 @@ func createRoom(
} }
createContent := map[string]interface{}{} createContent := map[string]interface{}{}
if err = json.Unmarshal(r.CreationContent, &createContent); err != nil { if len(r.CreationContent) > 0 {
return util.JSONResponse{ if err = json.Unmarshal(r.CreationContent, &createContent); err != nil {
Code: http.StatusBadRequest, return util.JSONResponse{
JSON: jsonerror.BadJSON("invalid create content"), Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON("invalid create content"),
}
} }
} }
createContent["creator"] = userID createContent["creator"] = userID