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

Prepare revision mail for the "Draft" status

Summary:
Ref T2543. Currently, we always do some special things when a revision is created, mostly adding more stuff to the mail.

With drafts, we want to suppress initial mail and send this big, rich mail only when the revision actually moves out of "draft".

Prepare the code for this, with the actual methods hard-coded to the current behavior. This will probably take some tweaking but I think I got most of it.

Test Plan: Banged around in Differential so it sent some mail, saw normal mail without anything new.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T2543

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

+64 -19
+1 -1
src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php
··· 24 24 PhabricatorApplicationTransactionEditor $editor, 25 25 array $xactions) { 26 26 27 - if ($editor->getIsNewObject()) { 27 + if ($editor->isFirstBroadcast()) { 28 28 return; 29 29 } 30 30
+1 -1
src/applications/differential/customfield/DifferentialSummaryField.php
··· 67 67 PhabricatorApplicationTransactionEditor $editor, 68 68 array $xactions) { 69 69 70 - if (!$editor->getIsNewObject()) { 70 + if (!$editor->isFirstBroadcast()) { 71 71 return; 72 72 } 73 73
+1 -1
src/applications/differential/customfield/DifferentialTestPlanField.php
··· 71 71 PhabricatorApplicationTransactionEditor $editor, 72 72 array $xactions) { 73 73 74 - if (!$editor->getIsNewObject()) { 74 + if (!$editor->isFirstBroadcast()) { 75 75 return; 76 76 } 77 77
+53 -16
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 26 26 return pht('%s created %s.', $author, $object); 27 27 } 28 28 29 + public function isFirstBroadcast() { 30 + return $this->getIsNewObject(); 31 + } 32 + 29 33 public function getDiffUpdateTransaction(array $xactions) { 30 34 $type_update = DifferentialTransaction::TYPE_UPDATE; 31 35 ··· 600 604 return array_values(array_merge($head, $tail)); 601 605 } 602 606 603 - protected function requireCapabilities( 604 - PhabricatorLiskDAO $object, 605 - PhabricatorApplicationTransaction $xaction) { 606 - 607 - switch ($xaction->getTransactionType()) {} 608 - 609 - return parent::requireCapabilities($object, $xaction); 610 - } 611 - 612 607 protected function shouldPublishFeedStory( 613 608 PhabricatorLiskDAO $object, 614 609 array $xactions) { 610 + 611 + if (!$object->shouldBroadcast()) { 612 + return false; 613 + } 614 + 615 615 return true; 616 616 } 617 617 618 618 protected function shouldSendMail( 619 619 PhabricatorLiskDAO $object, 620 620 array $xactions) { 621 + 622 + if (!$object->shouldBroadcast()) { 623 + return false; 624 + } 625 + 621 626 return true; 622 627 } 623 628 ··· 633 638 protected function getMailAction( 634 639 PhabricatorLiskDAO $object, 635 640 array $xactions) { 636 - $action = parent::getMailAction($object, $xactions); 637 641 638 - $strongest = $this->getStrongestAction($object, $xactions); 639 - switch ($strongest->getTransactionType()) { 640 - case DifferentialTransaction::TYPE_UPDATE: 641 - $count = new PhutilNumber($object->getLineCount()); 642 - $action = pht('%s, %s line(s)', $action, $count); 643 - break; 642 + $show_lines = false; 643 + if ($this->isFirstBroadcast()) { 644 + $action = pht('Request'); 645 + 646 + $show_lines = true; 647 + } else { 648 + $action = parent::getMailAction($object, $xactions); 649 + 650 + $strongest = $this->getStrongestAction($object, $xactions); 651 + $type_update = DifferentialTransaction::TYPE_UPDATE; 652 + if ($strongest->getTransactionType() == $type_update) { 653 + $show_lines = true; 654 + } 655 + } 656 + 657 + if ($show_lines) { 658 + $count = new PhutilNumber($object->getLineCount()); 659 + $action = pht('%s, %s line(s)', $action, $count); 644 660 } 645 661 646 662 return $action; ··· 678 694 protected function buildMailBody( 679 695 PhabricatorLiskDAO $object, 680 696 array $xactions) { 697 + 698 + $viewer = $this->requireActor(); 699 + 700 + // If this is the first time we're sending mail about this revision, we 701 + // generate mail for all prior transactions, not just whatever is being 702 + // applied now. This gets the "added reviewers" lines and other relevant 703 + // information into the mail. 704 + if ($this->isFirstBroadcast()) { 705 + $xactions = $this->loadUnbroadcastTransactions($object); 706 + } 681 707 682 708 $body = new PhabricatorMetaMTAMailBody(); 683 709 $body->setViewer($this->requireActor()); ··· 1489 1515 $diff->getPHID(), 1490 1516 $object->getPHID(), 1491 1517 $acting_phid); 1518 + } 1519 + 1520 + private function loadUnbroadcastTransactions($object) { 1521 + $viewer = $this->requireActor(); 1522 + 1523 + $xactions = id(new DifferentialTransactionQuery()) 1524 + ->setViewer($viewer) 1525 + ->withObjectPHIDs(array($object->getPHID())) 1526 + ->execute(); 1527 + 1528 + return array_reverse($xactions); 1492 1529 } 1493 1530 1494 1531 }
+8
src/applications/differential/storage/DifferentialRevision.php
··· 694 694 return $this; 695 695 } 696 696 697 + public function shouldBroadcast() { 698 + if (!$this->isDraft()) { 699 + return true; 700 + } 701 + 702 + return false; 703 + } 704 + 697 705 698 706 /* -( HarbormasterBuildableInterface )------------------------------------- */ 699 707