Differential D13897 Diff 33570 src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | if ($mail->getCcPHIDs()) { | ||||
$cc_list = $viewer->renderHandleList($mail->getCcPHIDs()); | $cc_list = $viewer->renderHandleList($mail->getCcPHIDs()); | ||||
} else { | } else { | ||||
$cc_list = pht('None'); | $cc_list = pht('None'); | ||||
} | } | ||||
$properties->addProperty( | $properties->addProperty( | ||||
pht('Cc'), | pht('Cc'), | ||||
$cc_list); | $cc_list); | ||||
$properties->addProperty( | |||||
pht('Sent'), | |||||
phabricator_datetime($mail->getDateCreated(), $viewer)); | |||||
$properties->addSectionHeader( | $properties->addSectionHeader( | ||||
pht('Message'), | pht('Message'), | ||||
PHUIPropertyListView::ICON_SUMMARY); | PHUIPropertyListView::ICON_SUMMARY); | ||||
if ($mail->hasSensitiveContent()) { | if ($mail->hasSensitiveContent()) { | ||||
$body = phutil_tag( | $body = phutil_tag( | ||||
'em', | 'em', | ||||
array(), | array(), | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | private function buildDeliveryProperties(PhabricatorMetaMTAMail $mail) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$properties = id(new PHUIPropertyListView()) | $properties = id(new PHUIPropertyListView()) | ||||
->setUser($viewer); | ->setUser($viewer); | ||||
$actors = $mail->getDeliveredActors(); | $actors = $mail->getDeliveredActors(); | ||||
$reasons = null; | $reasons = null; | ||||
if (!$actors) { | if (!$actors) { | ||||
// TODO: We can get rid of this special-cased message after these changes | if ($mail->getStatus() == PhabricatorMailOutboundStatus::STATUS_QUEUE) { | ||||
// have been live for a while, but provide a more tailored message for | $delivery = $this->renderEmptyMessage( | ||||
// now so things are a little less confusing for users. | |||||
if ($mail->getStatus() == PhabricatorMetaMTAMail::STATUS_SENT) { | |||||
$delivery = phutil_tag( | |||||
'em', | |||||
array(), | |||||
pht( | |||||
'This is an older message that predates recording delivery '. | |||||
'information, so none is available.')); | |||||
} else { | |||||
$delivery = phutil_tag( | |||||
'em', | |||||
array(), | |||||
pht( | pht( | ||||
'This message has not been delivered yet, so delivery information '. | 'This message has not been delivered yet, so delivery information '. | ||||
'is not available.')); | 'is not available.')); | ||||
} else { | |||||
$delivery = $this->renderEmptyMessage( | |||||
pht( | |||||
'This is an older message that predates recording delivery '. | |||||
'information, so none is available.')); | |||||
} | } | ||||
} else { | } else { | ||||
$actor = idx($actors, $viewer->getPHID()); | $actor = idx($actors, $viewer->getPHID()); | ||||
if (!$actor) { | if (!$actor) { | ||||
$delivery = phutil_tag( | $delivery = phutil_tag( | ||||
'em', | 'em', | ||||
array(), | array(), | ||||
pht('This message was not delivered to you.')); | pht('This message was not delivered to you.')); | ||||
Show All 37 Lines | if (!$actors) { | ||||
$reasons->addItem($item); | $reasons->addItem($item); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$properties->addProperty(pht('Delivery'), $delivery); | $properties->addProperty(pht('Delivery'), $delivery); | ||||
if ($reasons) { | if ($reasons) { | ||||
$properties->addProperty(pht('Reasons'), $reasons); | $properties->addProperty(pht('Reasons'), $reasons); | ||||
$properties->addProperty( | |||||
null, | |||||
$this->renderEmptyMessage( | |||||
pht( | |||||
'Delivery reasons are listed from weakest to strongest.'))); | |||||
} | |||||
$properties->addSectionHeader(pht('Routing Rules')); | |||||
$map = $mail->getDeliveredRoutingMap(); | |||||
$routing_detail = null; | |||||
if ($map === null) { | |||||
if ($mail->getStatus() == PhabricatorMailOutboundStatus::STATUS_QUEUE) { | |||||
$routing_result = $this->renderEmptyMessage( | |||||
pht( | |||||
'This message has not been sent yet, so routing rules have '. | |||||
'not been computed.')); | |||||
} else { | |||||
$routing_result = $this->renderEmptyMessage( | |||||
pht( | |||||
'This is an older message which predates routing rules.')); | |||||
} | |||||
} else { | |||||
$rule = idx($map, $viewer->getPHID()); | |||||
if ($rule === null) { | |||||
$rule = idx($map, 'default'); | |||||
} | |||||
if ($rule === null) { | |||||
$routing_result = $this->renderEmptyMessage( | |||||
pht( | |||||
'No routing rules applied when delivering this message to you.')); | |||||
} else { | |||||
$rule_const = $rule['rule']; | |||||
$reason_phid = $rule['reason']; | |||||
switch ($rule_const) { | |||||
case PhabricatorMailRoutingRule::ROUTE_AS_NOTIFICATION: | |||||
$routing_result = pht( | |||||
'This message was routed as a notification because it '. | |||||
'matched %s.', | |||||
$viewer->renderHandle($reason_phid)->render()); | |||||
break; | |||||
case PhabricatorMailRoutingRule::ROUTE_AS_MAIL: | |||||
$routing_result = pht( | |||||
'This message was routed as an email because it matched %s.', | |||||
$viewer->renderHandle($reason_phid)->render()); | |||||
break; | |||||
default: | |||||
$routing_result = pht('Unknown routing rule "%s".', $rule_const); | |||||
break; | |||||
} | |||||
} | |||||
$routing_rules = $mail->getDeliveredRoutingRules(); | |||||
if ($routing_rules) { | |||||
$rules = array(); | |||||
foreach ($routing_rules as $rule) { | |||||
$phids = idx($rule, 'phids'); | |||||
if ($phids === null) { | |||||
$rules[] = $rule; | |||||
} else if (in_array($viewer->getPHID(), $phids)) { | |||||
$rules[] = $rule; | |||||
} | |||||
} | |||||
// Reorder rules by strength. | |||||
foreach ($rules as $key => $rule) { | |||||
$const = $rule['routingRule']; | |||||
$phids = $rule['phids']; | |||||
if ($phids === null) { | |||||
$type = 'A'; | |||||
} else { | |||||
$type = 'B'; | |||||
} | |||||
$rules[$key]['strength'] = sprintf( | |||||
'~%s%08d', | |||||
$type, | |||||
PhabricatorMailRoutingRule::getRuleStrength($const)); | |||||
} | |||||
$rules = isort($rules, 'strength'); | |||||
$routing_detail = id(new PHUIStatusListView()); | |||||
foreach ($rules as $rule) { | |||||
$const = $rule['routingRule']; | |||||
$phids = $rule['phids']; | |||||
$name = PhabricatorMailRoutingRule::getRuleName($const); | |||||
$icon = PhabricatorMailRoutingRule::getRuleIcon($const); | |||||
$color = PhabricatorMailRoutingRule::getRuleColor($const); | |||||
if ($phids === null) { | |||||
$kind = pht('Global'); | |||||
} else { | |||||
$kind = pht('Personal'); | |||||
} | |||||
$target = array($kind, ': ', $name); | |||||
$target = phutil_tag('strong', array(), $target); | |||||
$item = id(new PHUIStatusItemView()) | |||||
->setTarget($target) | |||||
->setNote($viewer->renderHandle($rule['reasonPHID'])) | |||||
->setIcon($icon, $color); | |||||
$routing_detail->addItem($item); | |||||
} | |||||
} | |||||
} | |||||
$properties->addProperty(pht('Effective Rule'), $routing_result); | |||||
if ($routing_detail !== null) { | |||||
$properties->addProperty(pht('All Matching Rules'), $routing_detail); | |||||
$properties->addProperty( | |||||
null, | |||||
$this->renderEmptyMessage( | |||||
pht( | |||||
'Matching rules are listed from weakest to strongest.'))); | |||||
} | } | ||||
return $properties; | return $properties; | ||||
} | } | ||||
private function buildMetadataProperties(PhabricatorMetaMTAMail $mail) { | private function buildMetadataProperties(PhabricatorMetaMTAMail $mail) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
Show All 22 Lines | private function buildMetadataProperties(PhabricatorMetaMTAMail $mail) { | ||||
} else { | } else { | ||||
$related = phutil_tag('em', array(), pht('None')); | $related = phutil_tag('em', array(), pht('None')); | ||||
} | } | ||||
$properties->addProperty(pht('Related Object'), $related); | $properties->addProperty(pht('Related Object'), $related); | ||||
return $properties; | return $properties; | ||||
} | } | ||||
private function renderEmptyMessage($message) { | |||||
return phutil_tag('em', array(), $message); | |||||
} | |||||
} | } |