mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Disallow contentless Ponder answers
Summary: Any answer without non whitespace characters results in an error. Test Plan: - Submitted an empty answer, was told off - Submitted an answer full of whitespace, didn't like that either - Submitted a real answer, accepted Reviewers: pieter, epriestley, vrana Reviewed By: epriestley CC: aran, Korvin, davidreuss Maniphest Tasks: T1644 Differential Revision: https://secure.phabricator.com/D3492
This commit is contained in:
parent
cfea1d29ee
commit
e2ae82d455
2 changed files with 14 additions and 3 deletions
|
@ -34,6 +34,17 @@ final class PonderAnswerSaveController extends PonderController {
|
|||
|
||||
$answer = $request->getStr('answer');
|
||||
|
||||
// Only want answers with some non whitespace content
|
||||
if (!strlen(trim($answer))) {
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setUser($request->getUser());
|
||||
$dialog->setTitle('Empty answer');
|
||||
$dialog->appendChild('<p>Your answer must not be empty.</p>');
|
||||
$dialog->addCancelButton('/Q'.$question_id);
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
|
@ -55,8 +66,7 @@ final class PonderAnswerSaveController extends PonderController {
|
|||
|
||||
PhabricatorSearchPonderIndexer::indexQuestion($question);
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI(id(new PhutilURI('/Q'. $question->getID()))
|
||||
->setFragment('A'.$res->getID()));
|
||||
return id(new AphrontRedirectResponse())->setURI(
|
||||
id(new PhutilURI('/Q'. $question->getID())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ final class PonderAddAnswerView extends AphrontView {
|
|||
$form
|
||||
->setUser($this->user)
|
||||
->setAction($this->actionURI)
|
||||
->setWorkflow(true)
|
||||
->addHiddenInput('question_id', $question->getID())
|
||||
->appendChild(
|
||||
id(new AphrontFormTextAreaControl())
|
||||
|
|
Loading…
Reference in a new issue