mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-16 03:42:41 +01:00
444ced16d9
Summary: ...also re-jiggers all the anchor stuff to use $xaction ID. This seemed like the simplest way once I got in the code, as well as having nice properties for if / when we want to re-add some ajax stuff since the ID is a pretty solid piece of data to key off. Fixes T6083. Test Plan: mentioned DX in private DX+1. Could see on DX the mention as me and not as the other user. For transactions, I left a comment on Paste and it worked, and I edited an existing transaction and it worked. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T6083 Differential Revision: https://secure.phabricator.com/D10488
70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class PonderAnswerCommentController extends PonderController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
if (!$request->isFormPost()) {
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$answer = id(new PonderAnswerQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($this->id))
|
|
->executeOne();
|
|
if (!$answer) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$is_preview = $request->isPreviewRequest();
|
|
// $draft = PhabricatorDraft::buildFromRequest($request);
|
|
|
|
$qid = $answer->getQuestion()->getID();
|
|
$aid = $answer->getID();
|
|
$view_uri = "Q{$qid}#A{$aid}";
|
|
|
|
$xactions = array();
|
|
$xactions[] = id(new PonderAnswerTransaction())
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
->attachComment(
|
|
id(new PonderAnswerTransactionComment())
|
|
->setContent($request->getStr('comment')));
|
|
|
|
$editor = id(new PonderAnswerEditor())
|
|
->setActor($viewer)
|
|
->setContinueOnNoEffect($request->isContinueRequest())
|
|
->setContentSourceFromRequest($request)
|
|
->setIsPreview($is_preview);
|
|
|
|
try {
|
|
$xactions = $editor->applyTransactions($answer, $xactions);
|
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
|
->setCancelURI($view_uri)
|
|
->setException($ex);
|
|
}
|
|
|
|
// if ($draft) {
|
|
// $draft->replaceOrDelete();
|
|
// }
|
|
|
|
if ($request->isAjax() && $is_preview) {
|
|
return id(new PhabricatorApplicationTransactionResponse())
|
|
->setViewer($viewer)
|
|
->setTransactions($xactions)
|
|
->setIsPreview($is_preview);
|
|
} else {
|
|
return id(new AphrontRedirectResponse())
|
|
->setURI($view_uri);
|
|
}
|
|
}
|
|
|
|
}
|