diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php index 81382071ca..a77d931689 100644 --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -519,22 +519,6 @@ final class PhabricatorAuditEditor } - protected function shouldSendMail( - PhabricatorLiskDAO $object, - array $xactions) { - - // not every code path loads the repository so tread carefully - // TODO: They should, and then we should simplify this. - if ($object->getRepository($assert_attached = false)) { - $repository = $object->getRepository(); - if (!$repository->shouldPublish()) { - return false; - } - } - - return $this->isCommitMostlyImported($object); - } - protected function buildReplyHandler(PhabricatorLiskDAO $object) { $reply_handler = PhabricatorEnv::newObjectFromConfig( 'metamta.diffusion.reply-handler'); @@ -808,14 +792,6 @@ final class PhabricatorAuditEditor ); } - - - protected function shouldPublishFeedStory( - PhabricatorLiskDAO $object, - array $xactions) { - return $this->shouldSendMail($object, $xactions); - } - protected function shouldApplyHeraldRules( PhabricatorLiskDAO $object, array $xactions) { @@ -916,4 +892,39 @@ final class PhabricatorAuditEditor return $object->isPartiallyImported($mask); } + + private function shouldPublishRepositoryActivity( + PhabricatorLiskDAO $object, + array $xactions) { + + // not every code path loads the repository so tread carefully + // TODO: They should, and then we should simplify this. + if ($object->getRepository($assert_attached = false)) { + $repository = $object->getRepository(); + if (!$repository->shouldPublish()) { + return false; + } + } + + return $this->isCommitMostlyImported($object); + } + + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { + return $this->shouldPublishRepositoryActivity($object, $xactions); + } + + protected function shouldEnableMentions( + PhabricatorLiskDAO $object, + array $xactions) { + return $this->shouldPublishRepositoryActivity($object, $xactions); + } + + protected function shouldPublishFeedStory( + PhabricatorLiskDAO $object, + array $xactions) { + return $this->shouldPublishRepositoryActivity($object, $xactions); + } + } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 307418c3a7..d81f9f5c8d 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -186,6 +186,10 @@ abstract class PhabricatorApplicationTransactionEditor return $this->unmentionablePHIDMap; } + protected function shouldEnableMentions() { + return true; + } + public function setApplicationEmail( PhabricatorMetaMTAApplicationEmail $email) { $this->applicationEmail = $email; @@ -1052,10 +1056,14 @@ abstract class PhabricatorApplicationTransactionEditor return null; } - $texts = array_mergev($blocks); - $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions( - $this->getActor(), - $texts); + if ($this->shouldEnableMentions($object, $xactions)) { + $texts = array_mergev($blocks); + $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions( + $this->getActor(), + $texts); + } else { + $phids = array(); + } $this->mentionedPHIDs = $phids; @@ -1229,12 +1237,14 @@ abstract class PhabricatorApplicationTransactionEditor $engine); $mentioned_phids = array(); - foreach ($blocks as $key => $xaction_blocks) { - foreach ($xaction_blocks as $block) { - $engine->markupText($block); - $mentioned_phids += $engine->getTextMetadata( - PhabricatorObjectRemarkupRule::KEY_MENTIONED_OBJECTS, - array()); + if ($this->shouldEnableMentions($object, $xactions)) { + foreach ($blocks as $key => $xaction_blocks) { + foreach ($xaction_blocks as $block) { + $engine->markupText($block); + $mentioned_phids += $engine->getTextMetadata( + PhabricatorObjectRemarkupRule::KEY_MENTIONED_OBJECTS, + array()); + } } } @@ -1248,19 +1258,22 @@ abstract class PhabricatorApplicationTransactionEditor ->execute(); $mentionable_phids = array(); - foreach ($mentioned_objects as $mentioned_object) { - if ($mentioned_object instanceof PhabricatorMentionableInterface) { - $mentioned_phid = $mentioned_object->getPHID(); - if (idx($this->getUnmentionablePHIDMap(), $mentioned_phid)) { - continue; + if ($this->shouldEnableMentions($object, $xactions)) { + foreach ($mentioned_objects as $mentioned_object) { + if ($mentioned_object instanceof PhabricatorMentionableInterface) { + $mentioned_phid = $mentioned_object->getPHID(); + if (idx($this->getUnmentionablePHIDMap(), $mentioned_phid)) { + continue; + } + // don't let objects mention themselves + if ($object->getPHID() && $mentioned_phid == $object->getPHID()) { + continue; + } + $mentionable_phids[$mentioned_phid] = $mentioned_phid; } - // don't let objects mention themselves - if ($object->getPHID() && $mentioned_phid == $object->getPHID()) { - continue; - } - $mentionable_phids[$mentioned_phid] = $mentioned_phid; } } + if ($mentionable_phids) { $edge_type = PhabricatorObjectMentionsObjectEdgeType::EDGECONST; $block_xactions[] = newv(get_class(head($xactions)), array())