New proper types

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2020-04-10 15:50:39 +02:00 committed by Jonas Rittershofer
commit 7aa3f7ace0
4 changed files with 31 additions and 10 deletions

View file

@ -256,11 +256,16 @@ class ApiController extends Controller {
'text' => $text,
]);
if (array_search($type, Question::TYPES) === false) {
$this->logger->debug('Invalid type');
return new Http\JSONResponse(['message' => 'Invalid type'], Http::STATUS_BAD_REQUEST);
}
try {
$form = $this->formMapper->findById($formId);
} catch (IMapperException $e) {
$this->logger->debug('Could not find form');
return new Http\JSONResponse([], Http::STATUS_BAD_REQUEST);
return new Http\JSONResponse(['message' => 'Could not find form'], Http::STATUS_BAD_REQUEST);
}
if ($form->getOwnerId() !== $this->userId) {