mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Disallow contentless ponder questions
Test Plan: * submitted various comments (empty, whitespace, real) and verified response Reviewers: pieter, epriestley CC: vrana, aran, Korvin Maniphest Tasks: T1644 Differential Revision: https://secure.phabricator.com/D3505
This commit is contained in:
parent
e2ae82d455
commit
76d78acfae
2 changed files with 12 additions and 2 deletions
|
@ -40,6 +40,16 @@ final class PonderCommentSaveController extends PonderController {
|
|||
}
|
||||
$content = $request->getStr('content');
|
||||
|
||||
if (!strlen(trim($content))) {
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setUser($request->getUser());
|
||||
$dialog->setTitle('Empty comment');
|
||||
$dialog->appendChild('<p>Your comment must not be empty.</p>');
|
||||
$dialog->addCancelButton('/Q'.$question_id);
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
$res = new PonderComment();
|
||||
$res
|
||||
->setContent($content)
|
||||
|
@ -51,8 +61,7 @@ final class PonderCommentSaveController extends PonderController {
|
|||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI(
|
||||
id(new PhutilURI('/Q'. $question->getID()))
|
||||
->setFragment('comment-' . $res->getID()));
|
||||
id(new PhutilURI('/Q'. $question->getID())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ final class PonderAddCommentView extends AphrontView {
|
|||
$form
|
||||
->setUser($this->user)
|
||||
->setAction($this->actionURI)
|
||||
->setWorkflow(true)
|
||||
->addHiddenInput('target', $target)
|
||||
->addHiddenInput('question_id', $questionID)
|
||||
->appendChild(
|
||||
|
|
Loading…
Reference in a new issue