1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-01 09:28:22 +01:00

Explicitly list To and Cc in multiplexed email

Summary:
When we multiplex email, add information to the body with an explicit list of
recipients. Also add some headers if people want to write mail rules.

Test Plan:
Commented on a task and a revision, got reasonable looking emails about them.

Reviewed By: jungejason
Reviewers: aran, jungejason, tuomaspelkonen
CC: aran, jungejason, epriestley
Differential Revision: 272
This commit is contained in:
epriestley 2011-05-11 20:32:30 -07:00
parent 8391767d8c
commit 03b56c1035
2 changed files with 32 additions and 0 deletions

View file

@ -98,10 +98,30 @@ abstract class PhabricatorMailReplyHandler {
$groups[$private][] = $recipient;
}
// When multiplexing mail, explicitly include To/Cc information in the
// message body and headers.
$add_headers = array();
$body = $mail_template->getBody();
$body .= "\n";
if ($to_handles) {
$body .= "To: ".implode(', ', mpull($to_handles, 'getName'))."\n";
$add_headers['X-Phabricator-To'] = $this->formatPHIDList($to_handles);
}
if ($cc_handles) {
$body .= "Cc: ".implode(', ', mpull($cc_handles, 'getName'))."\n";
$add_headers['X-Phabricator-Cc'] = $this->formatPHIDList($cc_handles);
}
foreach ($groups as $reply_to => $group) {
$mail = clone $mail_template;
$mail->addTos(mpull($group, 'getPHID'));
$mail->setBody($body);
foreach ($add_headers as $header => $value) {
$mail->addHeader($header, $value);
}
if (!$reply_to) {
$reply_to = $this->getPublicReplyHandlerEmailAddress();
}
@ -116,6 +136,14 @@ abstract class PhabricatorMailReplyHandler {
return $result;
}
protected function formatPHIDList(array $handles) {
$list = array();
foreach ($handles as $handle) {
$list[] = '<'.$handle->getPHID().'>';
}
return implode(', ', $list);
}
protected function getDefaultPrivateReplyHandlerEmailAddress(
PhabricatorObjectHandle $handle,
$prefix) {

View file

@ -101,6 +101,10 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
return $this;
}
public function getBody() {
return $this->getParam('body');
}
public function setIsHTML($html) {
$this->setParam('is-html', $html);
return $this;