mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Add an X-Phabricator-Projects header to outbound mail
Summary: Fixes T4973. For `PhabricatorProjectInterface` objects, add a header to let clients do mail filtering. Test Plan: Saw `X-Phabricator-Projects: <#goat_farm>` in outbound mail. Reviewers: btrahan Reviewed By: btrahan Subscribers: rush898, epriestley Maniphest Tasks: T4973 Differential Revision: https://secure.phabricator.com/D10256
This commit is contained in:
parent
a37dc68b0a
commit
df28d751f5
1 changed files with 45 additions and 3 deletions
|
@ -1886,14 +1886,18 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
$template->addHeader('X-Herald-Rules', $herald_header);
|
||||
}
|
||||
|
||||
if ($object instanceof PhabricatorProjectInterface) {
|
||||
$this->addMailProjectMetadata($object, $template);
|
||||
}
|
||||
|
||||
if ($this->getParentMessageID()) {
|
||||
$template->setParentMessageID($this->getParentMessageID());
|
||||
}
|
||||
|
||||
$mails = $reply_handler->multiplexMail(
|
||||
$template,
|
||||
array_select_keys($handles, $email_to),
|
||||
array_select_keys($handles, $email_cc));
|
||||
$template,
|
||||
array_select_keys($handles, $email_to),
|
||||
array_select_keys($handles, $email_cc));
|
||||
|
||||
foreach ($mails as $mail) {
|
||||
$mail->saveAndSend();
|
||||
|
@ -1905,6 +1909,44 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
return $template;
|
||||
}
|
||||
|
||||
private function addMailProjectMetadata(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorMetaMTAMail $template) {
|
||||
|
||||
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$object->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
|
||||
if (!$project_phids) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: This viewer isn't quite right. It would be slightly better to use
|
||||
// the mail recipient, but that's not very easy given the way rendering
|
||||
// works today.
|
||||
|
||||
$handles = id(new PhabricatorHandleQuery())
|
||||
->setViewer($this->requireActor())
|
||||
->withPHIDs($project_phids)
|
||||
->execute();
|
||||
|
||||
$project_tags = array();
|
||||
foreach ($handles as $handle) {
|
||||
if (!$handle->isComplete()) {
|
||||
continue;
|
||||
}
|
||||
$project_tags[] = '<'.$handle->getObjectName().'>';
|
||||
}
|
||||
|
||||
if (!$project_tags) {
|
||||
return;
|
||||
}
|
||||
|
||||
$project_tags = implode(', ', $project_tags);
|
||||
$template->addHeader('X-Phabricator-Projects', $project_tags);
|
||||
}
|
||||
|
||||
|
||||
protected function getMailThreadID(PhabricatorLiskDAO $object) {
|
||||
return $object->getPHID();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue