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

Make "Receive Test" mail form use MailReceivers

Summary: Currently this is fairly hard-coded. Instead, make it use available receivers. Ref T1205.

Test Plan: Used mail form to send mail to various objects (Dnn, Tnn, Cnn, etc.). Only some of these work right now because the receiver thing still hard-codes a bunch of junk.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1205

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

+63 -5
+13
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 3 3 final class DiffusionCommitQuery 4 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 5 6 + private $ids; 6 7 private $identifiers; 7 8 private $phids; 8 9 private $defaultRepository; ··· 29 30 */ 30 31 public function withDefaultRepository(PhabricatorRepository $repository) { 31 32 $this->defaultRepository = $repository; 33 + return $this; 34 + } 35 + 36 + public function withIDs(array $ids) { 37 + $this->ids = $ids; 32 38 return $this; 33 39 } 34 40 ··· 162 168 } 163 169 164 170 $where[] = '('.implode(' OR ', $sql).')'; 171 + } 172 + 173 + if ($this->ids) { 174 + $where[] = qsprintf( 175 + $conn_r, 176 + 'id IN (%Ld)', 177 + $this->ids); 165 178 } 166 179 167 180 if ($this->phids) {
+46 -5
src/applications/metamta/controller/PhabricatorMetaMTAReceiveController.php
··· 19 19 20 20 if (!empty($from)) { 21 21 $header_content['from'] = $from; 22 + } else { 23 + // If the user doesn't provide a "From" address, use their primary 24 + // address. 25 + $header_content['from'] = $user->loadPrimaryEmail()->getAddress(); 22 26 } 23 27 24 28 if (preg_match('/.+@.+/', $to)) { 25 29 $header_content['to'] = $to; 26 30 } else { 27 - $receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject($to); 31 + 32 + // We allow the user to use an object name instead of a real address 33 + // as a convenience. To build the mail, we build a similar message and 34 + // look for a receiver which will accept it. 35 + $pseudohash = PhabricatorObjectMailReceiver::computeMailHash('x', 'y'); 36 + $pseudomail = id(new PhabricatorMetaMTAReceivedMail()) 37 + ->setHeaders( 38 + array( 39 + 'to' => $to.'+1+'.$pseudohash, 40 + )); 41 + 42 + $receivers = id(new PhutilSymbolLoader()) 43 + ->setAncestorClass('PhabricatorMailReceiver') 44 + ->loadObjects(); 45 + 46 + $receiver = null; 47 + foreach ($receivers as $possible_receiver) { 48 + if (!$possible_receiver->isEnabled()) { 49 + continue; 50 + } 51 + if (!$possible_receiver->canAcceptMail($pseudomail)) { 52 + continue; 53 + } 54 + $receiver = $possible_receiver; 55 + break; 56 + } 28 57 29 58 if (!$receiver) { 30 - throw new Exception(pht("No such task or revision!")); 59 + throw new Exception( 60 + "No configured mail receiver can accept mail to '{$to}'."); 61 + } 62 + 63 + if (!($receiver instanceof PhabricatorObjectMailReceiver)) { 64 + $class = get_class($receiver); 65 + throw new Exception( 66 + "Receiver '{$class}' accepts mail to '{$to}', but is not a ". 67 + "subclass of PhabricatorObjectMailReceiver."); 68 + } 69 + 70 + $object = $receiver->loadMailReceiverObject($to, $user); 71 + if (!$object) { 72 + throw new Exception("No such object '{$to}'!"); 31 73 } 32 74 33 75 $hash = PhabricatorObjectMailReceiver::computeMailHash( 34 - $receiver->getMailKey(), 76 + $object->getMailKey(), 35 77 $user->getPHID()); 36 78 37 - $header_content['to'] = 38 - $to.'+'.$user->getID().'+'.$hash.'@'; 79 + $header_content['to'] = $to.'+'.$user->getID().'+'.$hash.'@test.com'; 39 80 } 40 81 41 82 $received->setHeaders($header_content);
+4
src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php
··· 26 26 */ 27 27 abstract protected function loadObject($pattern, PhabricatorUser $viewer); 28 28 29 + public function loadMailReceiverObject($pattern, PhabricatorUser $viewer) { 30 + return $this->loadObject($pattern, $viewer); 31 + } 32 + 29 33 30 34 public function validateSender( 31 35 PhabricatorMetaMTAReceivedMail $mail,