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

Add implicit CC rules to ApplicationTransactions

Summary: When you make a comment on an object (or take certain other actions), we want to automatically CC you. Build this into ApplicationTransactions since it's a common behavior shared across multiple apps. Fixes T2215.

Test Plan: Made a comment on a macro, got cc'd.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T2215

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

+69 -1
+69 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 220 220 221 221 $this->validateEditParameters($object, $xactions); 222 222 223 + $actor = $this->requireActor(); 223 224 224 - $actor = $this->requireActor(); 225 + $xactions = $this->applyImplicitCC($object, $xactions); 225 226 226 227 $mention_xaction = $this->buildMentionTransaction($object, $xactions); 227 228 if ($mention_xaction) { ··· 641 642 return $xactions; 642 643 } 643 644 645 + 646 + /* -( Implicit CCs )------------------------------------------------------- */ 647 + 648 + 649 + /** 650 + * When a user interacts with an object, we might want to add them to CC. 651 + */ 652 + final public function applyImplicitCC( 653 + PhabricatorLiskDAO $object, 654 + array $xactions) { 655 + 656 + if (!($object instanceof PhabricatorSubscribableInterface)) { 657 + // If the object isn't subscribable, we can't CC them. 658 + return $xactions; 659 + } 660 + 661 + $actor_phid = $this->requireActor()->getPHID(); 662 + if ($object->isAutomaticallySubscribed($actor_phid)) { 663 + // If they're auto-subscribed, don't CC them. 664 + return $xactions; 665 + } 666 + 667 + $should_cc = false; 668 + foreach ($xactions as $xaction) { 669 + if ($this->shouldImplyCC($object, $xaction)) { 670 + $should_cc = true; 671 + break; 672 + } 673 + } 674 + 675 + if (!$should_cc) { 676 + // Only some types of actions imply a CC (like adding a comment). 677 + return $xactions; 678 + } 679 + 680 + if ($object->getPHID()) { 681 + $unsub = PhabricatorEdgeQuery::loadDestinationPHIDs( 682 + $object->getPHID(), 683 + PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER); 684 + $unsub = array_fuse($unsub); 685 + if (isset($unsub[$actor_phid])) { 686 + // If the user has previously unsubscribed from this object explicitly, 687 + // don't implicitly CC them. 688 + return $xactions; 689 + } 690 + } 691 + 692 + $xaction = newv(get_class(head($xactions)), array()); 693 + $xaction->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS); 694 + $xaction->setNewValue(array('+' => array($actor_phid))); 695 + 696 + array_unshift($xactions, $xaction); 697 + 698 + return $xactions; 699 + } 700 + 701 + protected function shouldImplyCC( 702 + PhabricatorLiskDAO $object, 703 + PhabricatorApplicationTransaction $xaction) { 704 + 705 + switch ($xaction->getTransactionType()) { 706 + case PhabricatorTransactions::TYPE_COMMENT: 707 + return true; 708 + default: 709 + return false; 710 + } 711 + } 644 712 645 713 646 714 /* -( Sending Mail )------------------------------------------------------- */