Differential D17252 Diff 41494 src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php
| Show All 24 Lines | final class DiffusionCommitConcernTransaction | ||||
| protected function getCommitActionOrder() { | protected function getCommitActionOrder() { | ||||
| return 600; | return 600; | ||||
| } | } | ||||
| public function getActionName() { | public function getActionName() { | ||||
| return pht('Raised Concern'); | return pht('Raised Concern'); | ||||
| } | } | ||||
| public function generateOldValue($object) { | public function applyInternalEffects($object, $value) { | ||||
| $actor = $this->getActor(); | // NOTE: We force the commit directly into "Concern Raised" so that we | ||||
| return $this->isViewerRejectingAuditor($object, $actor); | // override a possible "Needs Verification" state. | ||||
| $object->setAuditStatus( | |||||
| PhabricatorAuditCommitStatusConstants::CONCERN_RAISED); | |||||
| } | } | ||||
| public function applyExternalEffects($object, $value) { | public function applyExternalEffects($object, $value) { | ||||
| $status = PhabricatorAuditStatusConstants::CONCERNED; | $status = PhabricatorAuditStatusConstants::CONCERNED; | ||||
| $actor = $this->getActor(); | $actor = $this->getActor(); | ||||
| $this->applyAuditorEffect($object, $actor, $value, $status); | $this->applyAuditorEffect($object, $actor, $value, $status); | ||||
| } | } | ||||
| protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
| if ($this->isViewerCommitAuthor($object, $viewer)) { | if ($this->isViewerCommitAuthor($object, $viewer)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not raise a concern with this commit because you are '. | 'You can not raise a concern with this commit because you are '. | ||||
| 'the commit author. You can only raise concerns with commits '. | 'the commit author. You can only raise concerns with commits '. | ||||
| 'you did not author.')); | 'you did not author.')); | ||||
| } | } | ||||
| if ($this->isViewerRejectingAuditor($object, $viewer)) { | // Even if you've already raised a concern, you can raise again as long | ||||
| // as the author requsted you verify. | |||||
| $state_verify = PhabricatorAuditCommitStatusConstants::NEEDS_VERIFICATION; | |||||
| if ($this->isViewerFullyRejected($object, $viewer)) { | |||||
| if ($object->getAuditStatus() != $state_verify) { | |||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not raise a concern with this commit because you have '. | 'You can not raise a concern with this commit because you have '. | ||||
| 'already raised a concern with it.')); | 'already raised a concern with it.')); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| public function getTitle() { | public function getTitle() { | ||||
| return pht( | return pht( | ||||
| '%s raised a concern with this commit.', | '%s raised a concern with this commit.', | ||||
| $this->renderAuthor()); | $this->renderAuthor()); | ||||
| } | } | ||||
| public function getTitleForFeed() { | public function getTitleForFeed() { | ||||
| return pht( | return pht( | ||||
| '%s raised a concern with %s.', | '%s raised a concern with %s.', | ||||
| $this->renderAuthor(), | $this->renderAuthor(), | ||||
| $this->renderObject()); | $this->renderObject()); | ||||
| } | } | ||||
| } | } | ||||