Differential D11281 Diff 27175 src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
Show First 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | final public function multiplexMail( | ||||
$tos = mpull($to_handles, null, 'getPHID'); | $tos = mpull($to_handles, null, 'getPHID'); | ||||
$ccs = mpull($cc_handles, null, 'getPHID'); | $ccs = mpull($cc_handles, null, 'getPHID'); | ||||
// Merge all the recipients together. TODO: We could keep the CCs as real | // Merge all the recipients together. TODO: We could keep the CCs as real | ||||
// CCs and send to a "noreply@domain.com" type address, but keep it simple | // CCs and send to a "noreply@domain.com" type address, but keep it simple | ||||
// for now. | // for now. | ||||
$recipients = $tos + $ccs; | $recipients = $tos + $ccs; | ||||
// Check if all recipients have proper permissions to the object | |||||
// Remove them from the list otherwise | |||||
$recipient_users = id(new PhabricatorPeopleQuery()) | |||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | |||||
->withPHIDs(array_keys($recipients)) | |||||
->execute(); | |||||
$recipient_users = mpull($recipient_users, null, 'getPHID'); | |||||
phlog($recipient_users); | |||||
// Check if user has permissions to view this object | |||||
foreach ($recipients as $phid => $recipient) { | |||||
if ($this->mailReceiver | |||||
&& $this->mailReceiver instanceof PhabricatorPolicyInterface | |||||
&& idx($recipient_users, $phid) | |||||
&& $recipient_users[$phid] instanceof PhabricatorUser) { | |||||
if (!PhabricatorPolicyFilter::hasCapability( | |||||
$recipient_users[$phid], | |||||
$this->mailReceiver, | |||||
PhabricatorPolicyCapability::CAN_VIEW)) { | |||||
// User has no permission to this object | |||||
// so remove them from the recipient list | |||||
unset($recipients[$phid]); | |||||
} | |||||
} | |||||
} | |||||
if (!$recipients) { | |||||
return $result; | |||||
} | |||||
// When multiplexing mail, explicitly include To/Cc information in the | // When multiplexing mail, explicitly include To/Cc information in the | ||||
// message body and headers. | // message body and headers. | ||||
$mail_template = clone $mail_template; | $mail_template = clone $mail_template; | ||||
$mail_template->addPHIDHeaders('X-Phabricator-To', array_keys($tos)); | $mail_template->addPHIDHeaders('X-Phabricator-To', array_keys($tos)); | ||||
$mail_template->addPHIDHeaders('X-Phabricator-Cc', array_keys($ccs)); | $mail_template->addPHIDHeaders('X-Phabricator-Cc', array_keys($ccs)); | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |