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

Send several X-Differential-CC headers

Summary: People want to create filters checking if they are in CC which is almost impossible with multiplexing in Outlook.

Test Plan: Sent e-mail with multiple CCs, verified headers.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

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

vrana c5c0324e c5e504ff

+48 -32
+16 -4
src/applications/differential/mail/DifferentialMail.php
··· 110 110 'X-Differential-Author', 111 111 '<'.$revision->getAuthorPHID().'>'); 112 112 } 113 - if ($revision->getReviewers()) { 113 + 114 + $reviewer_phids = $revision->getReviewers(); 115 + if ($reviewer_phids) { 116 + // Add several headers to support e-mail clients which are not able to 117 + // create rules using regular expressions or wildcards (namely Outlook). 118 + $template->addPHIDHeaders('X-Differential-Reviewer', $reviewer_phids); 119 + 120 + // Add it also as a list to allow matching of the first reviewer and 121 + // also for backwards compatibility. 114 122 $template->addHeader( 115 123 'X-Differential-Reviewers', 116 - '<'.implode('>, <', $revision->getReviewers()).'>'); 124 + '<'.implode('>, <', $reviewer_phids).'>'); 117 125 } 118 - if ($revision->getCCPHIDs()) { 126 + 127 + $cc_phids = $revision->getCCPHIDs(); 128 + if ($cc_phids) { 129 + $template->addPHIDHeaders('X-Differential-CC', $cc_phids); 119 130 $template->addHeader( 120 131 'X-Differential-CCs', 121 - '<'.implode('>, <', $revision->getCCPHIDs()).'>'); 132 + '<'.implode('>, <', $cc_phids).'>'); 122 133 123 134 // Determine explicit CCs (those added by humans) and put them in a 124 135 // header so users can differentiate between Herald CCs and human CCs. ··· 142 153 } 143 154 144 155 if ($explicit_cc) { 156 + $template->addPHIDHeaders('X-Differential-Explicit-CC', $explicit_cc); 145 157 $template->addHeader( 146 158 'X-Differential-Explicit-CCs', 147 159 '<'.implode('>, <', $explicit_cc).'>');
+9 -21
src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
··· 118 118 } 119 119 } 120 120 121 + $tos = mpull($to_handles, null, 'getPHID'); 122 + $ccs = mpull($cc_handles, null, 'getPHID'); 123 + 121 124 // Merge all the recipients together. TODO: We could keep the CCs as real 122 125 // CCs and send to a "noreply@domain.com" type address, but keep it simple 123 126 // for now. 124 - $recipients = mpull($to_handles, null, 'getPHID') + 125 - mpull($cc_handles, null, 'getPHID'); 127 + $recipients = $tos + $ccs; 126 128 127 129 // When multiplexing mail, explicitly include To/Cc information in the 128 130 // message body and headers. 129 - $add_headers = array(); 131 + 132 + $mail_template = clone $mail_template; 133 + 134 + $mail_template->addPHIDHeaders('X-Phabricator-To', array_keys($tos)); 135 + $mail_template->addPHIDHeaders('X-Phabricator-Cc', array_keys($ccs)); 130 136 131 137 $body = $mail_template->getBody(); 132 138 $body .= "\n"; 133 - if ($to_handles) { 134 - $add_headers['X-Phabricator-To'] = $this->formatPHIDList($to_handles); 135 - } 136 - if ($cc_handles) { 137 - $add_headers['X-Phabricator-Cc'] = $this->formatPHIDList($cc_handles); 138 - } 139 139 $body .= $this->getRecipientsSummary($to_handles, $cc_handles); 140 140 141 141 foreach ($recipients as $recipient) { ··· 143 143 $mail->addTos(array($recipient->getPHID())); 144 144 145 145 $mail->setBody($body); 146 - foreach ($add_headers as $header => $value) { 147 - $mail->addHeader($header, $value); 148 - } 149 146 150 147 $reply_to = null; 151 148 if (!$reply_to && $this->supportsPrivateReplies()) { ··· 164 161 } 165 162 166 163 return $result; 167 - } 168 - 169 - protected function formatPHIDList(array $handles) { 170 - assert_instances_of($handles, 'PhabricatorObjectHandle'); 171 - $list = array(); 172 - foreach ($handles as $handle) { 173 - $list[] = '<'.$handle->getPHID().'>'; 174 - } 175 - return implode(', ', $list); 176 164 } 177 165 178 166 protected function getDefaultPublicReplyHandlerEmailAddress($prefix) {
+11 -2
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
··· 141 141 return $return; 142 142 } 143 143 144 + public function addPHIDHeaders($name, array $phids) { 145 + foreach ($phids as $phid) { 146 + $this->addHeader($name, '<'.$phid.'>'); 147 + } 148 + return $this; 149 + } 150 + 144 151 public function addHeader($name, $value) { 145 - $this->parameters['headers'][$name] = $value; 152 + $this->parameters['headers'][] = array($name, $value); 146 153 return $this; 147 154 } 148 155 ··· 408 415 } 409 416 break; 410 417 case 'headers': 411 - foreach ($value as $header_key => $header_value) { 418 + foreach ($value as $pair) { 419 + list($header_key, $header_value) = $pair; 420 + 412 421 // NOTE: If we have \n in a header, SES rejects the email. 413 422 $header_value = str_replace("\n", " ", $header_value); 414 423
+12 -5
src/docs/userguide/mail_rules.diviner
··· 34 34 Phabricator sends a variety of mail headers that can be useful in crafting rules 35 35 to route and manage mail. 36 36 37 - Many of these headers contain lists. A list containing two items, ##1## and 37 + Headers in plural contain lists. A list containing two items, ##1## and 38 38 ##15## will generally be formatted like this: 39 39 40 40 X-Header: <1>, <15> ··· 43 43 just match against "1", you'll incorrectly match "15", but matching "<1>" will 44 44 correctly match only "<1>". 45 45 46 + Some other headers use a single value but can be presented multiple times. 47 + It is to support e-mail clients which are not able to create rules using regular 48 + expressions or wildcards (namely Outlook). 49 + 46 50 The headers Phabricator adds to mail are: 47 51 48 52 - ##X-Phabricator-Sent-This-Message##: this is attached to all mail 49 53 Phabricator sends. You can use it to differentiate between email from 50 54 Phabricator and replies/forwards of Phabricator mail from human beings. 51 55 - ##X-Phabricator-To##: this is attached to all mail Phabricator sends. 52 - It this shows the PHIDs of the original "To" line, before any mutation 56 + It shows the PHIDs of the original "To" line, before any mutation 53 57 by the mailer configuration. 54 58 - ##X-Phabricator-Cc##: this is attached to all mail Phabricator sends. 55 59 It shows the PHIDs of the original "Cc" line, before any mutation by the ··· 57 61 - ##X-Differential-Author##: this is attached to Differential mail and shows 58 62 the revision's author. You can use it to filter mail about your revisions 59 63 (or other users' revisions). 60 - - ##X-Differential-Reviewers##: this is attached to Differential mail and 64 + - ##X-Differential-Reviewer##: this is attached to Differential mail and 61 65 shows the reviewers. You can use it to filter mail about revisions you 62 66 are reviewing, versus revisions you are explicitly CC'd on or CC'd as 63 67 a result of Herald rules. 64 - - ##X-Differential-CCs##: this is attached to Differential mail and shows 68 + - ##X-Differential-Reviewers##: list version of the previous. 69 + - ##X-Differential-CC##: this is attached to Differential mail and shows 65 70 the CCs on the revision. 66 - - ##X-Differential-Explicit-CCs##: this is attached to Differential mail and 71 + - ##X-Differential-CCs##: list version of the previous. 72 + - ##X-Differential-Explicit-CC##: this is attached to Differential mail and 67 73 shows the explicit CCs on the revision (those that were added by humans, 68 74 not by Herald). 75 + - ##X-Differential-Explicit-CCs##: list version of the previous. 69 76 - ##X-Phabricator-Mail-Tags##: this is attached to some mail and has 70 77 a list of descriptors about the mail. (This is fairly new and subject 71 78 to some change.)