@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Disable mentions in nonpublishing repositories

Summary:
Ref T6516. Although this behavior is somewhat-arguable as desirable, I think it's less surprising and more consistent to disable mentions when a repository is publishing.

In particular, if you import a repository developed on another Phabricator install, this stops all the `T123` in commit messages from creating mentions on your unrelated `T123` tasks.

We already disable autoclose, so `Closes T123` and `Ref T123` already have no effect, but a bare `T123` would generate a mention. Likewise, `@epriestley` would generate a mention.

If you import such a repository and then update it periodically, updates will activate autoclose and publishing (if you didn't disable them), but presumably this will hit a couple of tasks and you'll go change the settings if you forgot.

At some point, we may have some kind of use case for separating the "publish" setting into a "publish" setting and a "this is a local repository" setting. For example, if you work at Widget Corp, want to import Phabricator locally, //and// want to write Herald rules against it, you can't currently configure the repository to let you do all of this. But we haven't actually seen a use case for this yet.

Test Plan:
- Pushed some commits with bare `T11`, saw mentions.
- Disabled publishing for the repository, pushed some commits with
- Imported a bunch of commits without seeing pipeline failures.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6516

Differential Revision: https://secure.phabricator.com/D11966

+68 -44
+35 -24
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 519 519 } 520 520 521 521 522 - protected function shouldSendMail( 523 - PhabricatorLiskDAO $object, 524 - array $xactions) { 525 - 526 - // not every code path loads the repository so tread carefully 527 - // TODO: They should, and then we should simplify this. 528 - if ($object->getRepository($assert_attached = false)) { 529 - $repository = $object->getRepository(); 530 - if (!$repository->shouldPublish()) { 531 - return false; 532 - } 533 - } 534 - 535 - return $this->isCommitMostlyImported($object); 536 - } 537 - 538 522 protected function buildReplyHandler(PhabricatorLiskDAO $object) { 539 523 $reply_handler = PhabricatorEnv::newObjectFromConfig( 540 524 'metamta.diffusion.reply-handler'); ··· 808 792 ); 809 793 } 810 794 811 - 812 - 813 - protected function shouldPublishFeedStory( 814 - PhabricatorLiskDAO $object, 815 - array $xactions) { 816 - return $this->shouldSendMail($object, $xactions); 817 - } 818 - 819 795 protected function shouldApplyHeraldRules( 820 796 PhabricatorLiskDAO $object, 821 797 array $xactions) { ··· 914 890 $mask = ($has_message | $has_changes); 915 891 916 892 return $object->isPartiallyImported($mask); 893 + } 894 + 895 + 896 + private function shouldPublishRepositoryActivity( 897 + PhabricatorLiskDAO $object, 898 + array $xactions) { 899 + 900 + // not every code path loads the repository so tread carefully 901 + // TODO: They should, and then we should simplify this. 902 + if ($object->getRepository($assert_attached = false)) { 903 + $repository = $object->getRepository(); 904 + if (!$repository->shouldPublish()) { 905 + return false; 906 + } 907 + } 908 + 909 + return $this->isCommitMostlyImported($object); 910 + } 911 + 912 + protected function shouldSendMail( 913 + PhabricatorLiskDAO $object, 914 + array $xactions) { 915 + return $this->shouldPublishRepositoryActivity($object, $xactions); 916 + } 917 + 918 + protected function shouldEnableMentions( 919 + PhabricatorLiskDAO $object, 920 + array $xactions) { 921 + return $this->shouldPublishRepositoryActivity($object, $xactions); 922 + } 923 + 924 + protected function shouldPublishFeedStory( 925 + PhabricatorLiskDAO $object, 926 + array $xactions) { 927 + return $this->shouldPublishRepositoryActivity($object, $xactions); 917 928 } 918 929 919 930 }
+33 -20
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 186 186 return $this->unmentionablePHIDMap; 187 187 } 188 188 189 + protected function shouldEnableMentions() { 190 + return true; 191 + } 192 + 189 193 public function setApplicationEmail( 190 194 PhabricatorMetaMTAApplicationEmail $email) { 191 195 $this->applicationEmail = $email; ··· 1052 1056 return null; 1053 1057 } 1054 1058 1055 - $texts = array_mergev($blocks); 1056 - $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions( 1057 - $this->getActor(), 1058 - $texts); 1059 + if ($this->shouldEnableMentions($object, $xactions)) { 1060 + $texts = array_mergev($blocks); 1061 + $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions( 1062 + $this->getActor(), 1063 + $texts); 1064 + } else { 1065 + $phids = array(); 1066 + } 1059 1067 1060 1068 $this->mentionedPHIDs = $phids; 1061 1069 ··· 1229 1237 $engine); 1230 1238 1231 1239 $mentioned_phids = array(); 1232 - foreach ($blocks as $key => $xaction_blocks) { 1233 - foreach ($xaction_blocks as $block) { 1234 - $engine->markupText($block); 1235 - $mentioned_phids += $engine->getTextMetadata( 1236 - PhabricatorObjectRemarkupRule::KEY_MENTIONED_OBJECTS, 1237 - array()); 1240 + if ($this->shouldEnableMentions($object, $xactions)) { 1241 + foreach ($blocks as $key => $xaction_blocks) { 1242 + foreach ($xaction_blocks as $block) { 1243 + $engine->markupText($block); 1244 + $mentioned_phids += $engine->getTextMetadata( 1245 + PhabricatorObjectRemarkupRule::KEY_MENTIONED_OBJECTS, 1246 + array()); 1247 + } 1238 1248 } 1239 1249 } 1240 1250 ··· 1248 1258 ->execute(); 1249 1259 1250 1260 $mentionable_phids = array(); 1251 - foreach ($mentioned_objects as $mentioned_object) { 1252 - if ($mentioned_object instanceof PhabricatorMentionableInterface) { 1253 - $mentioned_phid = $mentioned_object->getPHID(); 1254 - if (idx($this->getUnmentionablePHIDMap(), $mentioned_phid)) { 1255 - continue; 1256 - } 1257 - // don't let objects mention themselves 1258 - if ($object->getPHID() && $mentioned_phid == $object->getPHID()) { 1259 - continue; 1261 + if ($this->shouldEnableMentions($object, $xactions)) { 1262 + foreach ($mentioned_objects as $mentioned_object) { 1263 + if ($mentioned_object instanceof PhabricatorMentionableInterface) { 1264 + $mentioned_phid = $mentioned_object->getPHID(); 1265 + if (idx($this->getUnmentionablePHIDMap(), $mentioned_phid)) { 1266 + continue; 1267 + } 1268 + // don't let objects mention themselves 1269 + if ($object->getPHID() && $mentioned_phid == $object->getPHID()) { 1270 + continue; 1271 + } 1272 + $mentionable_phids[$mentioned_phid] = $mentioned_phid; 1260 1273 } 1261 - $mentionable_phids[$mentioned_phid] = $mentioned_phid; 1262 1274 } 1263 1275 } 1276 + 1264 1277 if ($mentionable_phids) { 1265 1278 $edge_type = PhabricatorObjectMentionsObjectEdgeType::EDGECONST; 1266 1279 $block_xactions[] = newv(get_class(head($xactions)), array())