1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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
extends PhabricatorAuditController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
if (!$request->isFormPost()) {
return new Aphront403Response();
@ -13,7 +12,7 @@ final class PhabricatorAuditAddCommentController
$commit_phid = $request->getStr('commit');
$commit = id(new DiffusionCommitQuery())
->setViewer($user)
->setViewer($viewer)
->withPHIDs(array($commit_phid))
->needAuditRequests(true)
->executeOne();
@ -61,7 +60,7 @@ final class PhabricatorAuditAddCommentController
}
$inlines = PhabricatorAuditInlineComment::loadDraftComments(
$user,
$viewer,
$commit->getPHID());
foreach ($inlines as $inline) {
$xactions[] = id(new PhabricatorAuditTransaction())
@ -70,14 +69,14 @@ final class PhabricatorAuditAddCommentController
}
id(new PhabricatorAuditEditor())
->setActor($user)
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->applyTransactions($commit, $xactions);
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$viewer->getPHID(),
'diffusion-audit-'.$commit->getID());
if ($draft) {
$draft->delete();

View file

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