1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Update Audit for handleRequest

Summary: Updates Audit controllers for handleRequest

Test Plan: See list of audits, raise concern, clear concern, comment.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13771
This commit is contained in:
Chad Little 2015-08-01 16:57:18 -07:00
parent 36103dfa18
commit f087bce27d
2 changed files with 15 additions and 22 deletions

View file

@ -3,9 +3,8 @@
final class PhabricatorAuditAddCommentController final class PhabricatorAuditAddCommentController
extends PhabricatorAuditController { extends PhabricatorAuditController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$user = $request->getUser();
if (!$request->isFormPost()) { if (!$request->isFormPost()) {
return new Aphront403Response(); return new Aphront403Response();
@ -13,7 +12,7 @@ final class PhabricatorAuditAddCommentController
$commit_phid = $request->getStr('commit'); $commit_phid = $request->getStr('commit');
$commit = id(new DiffusionCommitQuery()) $commit = id(new DiffusionCommitQuery())
->setViewer($user) ->setViewer($viewer)
->withPHIDs(array($commit_phid)) ->withPHIDs(array($commit_phid))
->needAuditRequests(true) ->needAuditRequests(true)
->executeOne(); ->executeOne();
@ -61,7 +60,7 @@ final class PhabricatorAuditAddCommentController
} }
$inlines = PhabricatorAuditInlineComment::loadDraftComments( $inlines = PhabricatorAuditInlineComment::loadDraftComments(
$user, $viewer,
$commit->getPHID()); $commit->getPHID());
foreach ($inlines as $inline) { foreach ($inlines as $inline) {
$xactions[] = id(new PhabricatorAuditTransaction()) $xactions[] = id(new PhabricatorAuditTransaction())
@ -70,14 +69,14 @@ final class PhabricatorAuditAddCommentController
} }
id(new PhabricatorAuditEditor()) id(new PhabricatorAuditEditor())
->setActor($user) ->setActor($viewer)
->setContentSourceFromRequest($request) ->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true) ->setContinueOnMissingFields(true)
->applyTransactions($commit, $xactions); ->applyTransactions($commit, $xactions);
$draft = id(new PhabricatorDraft())->loadOneWhere( $draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s', 'authorPHID = %s AND draftKey = %s',
$user->getPHID(), $viewer->getPHID(),
'diffusion-audit-'.$commit->getID()); 'diffusion-audit-'.$commit->getID());
if ($draft) { if ($draft) {
$draft->delete(); $draft->delete();

View file

@ -3,17 +3,11 @@
final class PhabricatorAuditPreviewController final class PhabricatorAuditPreviewController
extends PhabricatorAuditController { extends PhabricatorAuditController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function willProcessRequest(array $data) { $commit = id(new PhabricatorRepositoryCommit())->load($id);
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$commit = id(new PhabricatorRepositoryCommit())->load($this->id);
if (!$commit) { if (!$commit) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -23,7 +17,7 @@ final class PhabricatorAuditPreviewController
$action = $request->getStr('action'); $action = $request->getStr('action');
if ($action != PhabricatorAuditActionConstants::COMMENT) { if ($action != PhabricatorAuditActionConstants::COMMENT) {
$action_xaction = id(new PhabricatorAuditTransaction()) $action_xaction = id(new PhabricatorAuditTransaction())
->setAuthorPHID($user->getPHID()) ->setAuthorPHID($viewer->getPHID())
->setObjectPHID($commit->getPHID()) ->setObjectPHID($commit->getPHID())
->setTransactionType(PhabricatorAuditActionConstants::ACTION) ->setTransactionType(PhabricatorAuditActionConstants::ACTION)
->setNewValue($action); ->setNewValue($action);
@ -52,7 +46,7 @@ final class PhabricatorAuditPreviewController
$content = $request->getStr('content'); $content = $request->getStr('content');
if (strlen($content)) { if (strlen($content)) {
$xactions[] = id(new PhabricatorAuditTransaction()) $xactions[] = id(new PhabricatorAuditTransaction())
->setAuthorPHID($user->getPHID()) ->setAuthorPHID($viewer->getPHID())
->setObjectPHID($commit->getPHID()) ->setObjectPHID($commit->getPHID())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment( ->attachComment(
@ -72,13 +66,13 @@ final class PhabricatorAuditPreviewController
$view = id(new PhabricatorAuditTransactionView()) $view = id(new PhabricatorAuditTransactionView())
->setIsPreview(true) ->setIsPreview(true)
->setUser($user) ->setUser($viewer)
->setObjectPHID($commit->getPHID()) ->setObjectPHID($commit->getPHID())
->setTransactions($xactions); ->setTransactions($xactions);
id(new PhabricatorDraft()) id(new PhabricatorDraft())
->setAuthorPHID($user->getPHID()) ->setAuthorPHID($viewer->getPHID())
->setDraftKey('diffusion-audit-'.$this->id) ->setDraftKey('diffusion-audit-'.$id)
->setDraft($content) ->setDraft($content)
->replaceOrDelete(); ->replaceOrDelete();