private function returnSaveAddressResponse(AphrontRequest $request, PhutilURI $uri, PhabricatorMetaMTAApplicationEmail $email_object, $is_new)
 {
     $viewer = $request->getUser();
     $config_default = PhabricatorMetaMTAApplicationEmail::CONFIG_DEFAULT_AUTHOR;
     $e_email = true;
     $v_email = $email_object->getAddress();
     $e_space = null;
     $v_space = $email_object->getSpacePHID();
     $v_default = $email_object->getConfigValue($config_default);
     $validation_exception = null;
     if ($request->isDialogFormPost()) {
         $e_email = null;
         $v_email = trim($request->getStr('email'));
         $v_space = $request->getStr('spacePHID');
         $v_default = $request->getArr($config_default);
         $v_default = nonempty(head($v_default), null);
         $type_address = PhabricatorMetaMTAApplicationEmailTransaction::TYPE_ADDRESS;
         $type_space = PhabricatorTransactions::TYPE_SPACE;
         $type_config = PhabricatorMetaMTAApplicationEmailTransaction::TYPE_CONFIG;
         $key_config = PhabricatorMetaMTAApplicationEmailTransaction::KEY_CONFIG;
         $xactions = array();
         $xactions[] = id(new PhabricatorMetaMTAApplicationEmailTransaction())->setTransactionType($type_address)->setNewValue($v_email);
         $xactions[] = id(new PhabricatorMetaMTAApplicationEmailTransaction())->setTransactionType($type_space)->setNewValue($v_space);
         $xactions[] = id(new PhabricatorMetaMTAApplicationEmailTransaction())->setTransactionType($type_config)->setMetadataValue($key_config, $config_default)->setNewValue($v_default);
         $editor = id(new PhabricatorMetaMTAApplicationEmailEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
         try {
             $editor->applyTransactions($email_object, $xactions);
             return id(new AphrontRedirectResponse())->setURI($uri->alter('highlight', $email_object->getID()));
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
             $e_email = $ex->getShortMessage($type_address);
             $e_space = $ex->getShortMessage($type_space);
         }
     }
     if ($v_default) {
         $v_default = array($v_default);
     } else {
         $v_default = array();
     }
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Email'))->setName('email')->setValue($v_email)->setError($e_email));
     if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
         $form->appendControl(id(new AphrontFormSelectControl())->setLabel(pht('Space'))->setName('spacePHID')->setValue($v_space)->setError($e_space)->setOptions(PhabricatorSpacesNamespaceQuery::getSpaceOptionsForViewer($viewer, $v_space)));
     }
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setLabel(pht('Default Author'))->setName($config_default)->setLimit(1)->setValue($v_default)->setCaption(pht('Used if the "From:" address does not map to a known account.')));
     if ($is_new) {
         $title = pht('New Address');
     } else {
         $title = pht('Edit Address');
     }
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle($title)->setValidationException($validation_exception)->appendForm($form)->addSubmitButton(pht('Save'))->addCancelButton($uri);
     if ($is_new) {
         $dialog->addHiddenInput('new', 'true');
     }
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }