@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.

Propagate "unexpandable" PHIDs to feed notification recipient expansion

Summary:
See PHI466. Ref T13108. Somewhat recently, new rules were added so that "Resigning" from a revision takes you off the default recipient list, even if you're still a member of a project or package that is still a reviewer or subscriber.

However, these rules don't currently apply to the similar expansion which occurs in notifications. If you resign from a revision you may still get some notifications (just not email) if a package or project you're a member of is a reviewer or subscriber.

(Possibly these should eventually share more code, but just get things working for now.)

Test Plan:
- Created a revision as A.
- Added B as a reviewer.
- Added a package B is an owner for as a reviewer.
- As B, resigned. (Make sure B is also not an explicit subscriber.)
- Commented on the revision as A.
- Before: B is included in the expanded notification recipient list.
- After: B is no longer included in the expanded notification recipient list.

Maniphest Tasks: T13108

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

+43 -1
+37 -1
src/applications/feed/PhabricatorFeedStoryPublisher.php
··· 12 12 private $mailRecipientPHIDs = array(); 13 13 private $notifyAuthor; 14 14 private $mailTags = array(); 15 + private $unexpandablePHIDs = array(); 15 16 16 17 public function setMailTags(array $mail_tags) { 17 18 $this->mailTags = $mail_tags; ··· 44 45 public function setPrimaryObjectPHID($phid) { 45 46 $this->primaryObjectPHID = $phid; 46 47 return $this; 48 + } 49 + 50 + public function setUnexpandablePHIDs(array $unexpandable_phids) { 51 + $this->unexpandablePHIDs = $unexpandable_phids; 52 + return $this; 53 + } 54 + 55 + public function getUnexpandablePHIDs() { 56 + return $this->unexpandablePHIDs; 47 57 } 48 58 49 59 public function setStoryType($story_type) { ··· 254 264 } 255 265 256 266 private function expandRecipients(array $phids) { 257 - return id(new PhabricatorMetaMTAMemberQuery()) 267 + $expanded_phids = id(new PhabricatorMetaMTAMemberQuery()) 258 268 ->setViewer(PhabricatorUser::getOmnipotentUser()) 259 269 ->withPHIDs($phids) 260 270 ->executeExpansion(); 271 + 272 + // Filter out unexpandable PHIDs from the results. The typical case for 273 + // this is that resigned reviewers should not be notified just because 274 + // they are a member of some project or package reviewer. 275 + 276 + $original_map = array_fuse($phids); 277 + $unexpandable_map = array_fuse($this->unexpandablePHIDs); 278 + 279 + foreach ($expanded_phids as $key => $phid) { 280 + // We can keep this expanded PHID if it was present originally. 281 + if (isset($original_map[$phid])) { 282 + continue; 283 + } 284 + 285 + // We can also keep it if it isn't marked as unexpandable. 286 + if (!isset($unexpandable_map[$phid])) { 287 + continue; 288 + } 289 + 290 + // If it's unexpandable and we produced it by expanding recipients, 291 + // throw it away. 292 + unset($expanded_phids[$key]); 293 + } 294 + $expanded_phids = array_values($expanded_phids); 295 + 296 + return $expanded_phids; 261 297 } 262 298 263 299 /**
+6
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 3199 3199 $story_type = $this->getFeedStoryType(); 3200 3200 $story_data = $this->getFeedStoryData($object, $xactions); 3201 3201 3202 + $unexpandable_phids = $this->mailUnexpandablePHIDs; 3203 + if (!is_array($unexpandable_phids)) { 3204 + $unexpandable_phids = array(); 3205 + } 3206 + 3202 3207 id(new PhabricatorFeedStoryPublisher()) 3203 3208 ->setStoryType($story_type) 3204 3209 ->setStoryData($story_data) ··· 3207 3212 ->setRelatedPHIDs($related_phids) 3208 3213 ->setPrimaryObjectPHID($object->getPHID()) 3209 3214 ->setSubscribedPHIDs($subscribed_phids) 3215 + ->setUnexpandablePHIDs($unexpandable_phids) 3210 3216 ->setMailRecipientPHIDs($mailed_phids) 3211 3217 ->setMailTags($this->getMailTags($object, $xactions)) 3212 3218 ->publish();