Differential D10272 Diff 24753 src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php
Show All 11 Lines | $this | ||||
->setArguments( | ->setArguments( | ||||
array( | array( | ||||
array( | array( | ||||
'name' => 'id', | 'name' => 'id', | ||||
'param' => 'id', | 'param' => 'id', | ||||
'help' => 'Show details about outbound mail with given ID.', | 'help' => 'Show details about outbound mail with given ID.', | ||||
'repeat' => true, | 'repeat' => true, | ||||
), | ), | ||||
array( | |||||
'name' => 'dump-html', | |||||
'help' => pht( | |||||
'Dump the HTML body of the mail. You can redirect it to a '. | |||||
'file and then open it in a browser.'), | |||||
), | |||||
)); | )); | ||||
} | } | ||||
public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$ids = $args->getArg('id'); | $ids = $args->getArg('id'); | ||||
if (!$ids) { | if (!$ids) { | ||||
Show All 12 Lines | if ($ids) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
'Some specified messages do not exist: '. | 'Some specified messages do not exist: '. | ||||
implode(', ', array_keys($missing))); | implode(', ', array_keys($missing))); | ||||
} | } | ||||
} | } | ||||
$last_key = last_key($messages); | $last_key = last_key($messages); | ||||
foreach ($messages as $message_key => $message) { | foreach ($messages as $message_key => $message) { | ||||
if ($args->getArg('dump-html')) { | |||||
$html_body = $message->getHTMLBody(); | |||||
if (strlen($html_body)) { | |||||
$template = | |||||
"<!doctype html><html><body>{$html_body}</body></html>"; | |||||
$console->writeOut("%s\n", $html_body); | |||||
} else { | |||||
$console->writeErr( | |||||
"%s\n", | |||||
pht('(This message has no HTML body.)')); | |||||
} | |||||
continue; | |||||
} | |||||
$info = array(); | $info = array(); | ||||
$info[] = pht('PROPERTIES'); | $info[] = pht('PROPERTIES'); | ||||
$info[] = pht('ID: %d', $message->getID()); | $info[] = pht('ID: %d', $message->getID()); | ||||
$info[] = pht('Status: %s', $message->getStatus()); | $info[] = pht('Status: %s', $message->getStatus()); | ||||
$info[] = pht('Related PHID: %s', $message->getRelatedPHID()); | $info[] = pht('Related PHID: %s', $message->getRelatedPHID()); | ||||
$info[] = pht('Message: %s', $message->getMessage()); | $info[] = pht('Message: %s', $message->getMessage()); | ||||
$info[] = null; | $info[] = null; | ||||
$info[] = pht('PARAMETERS'); | $info[] = pht('PARAMETERS'); | ||||
$parameters = $message->getParameters(); | $parameters = $message->getParameters(); | ||||
foreach ($parameters as $key => $value) { | foreach ($parameters as $key => $value) { | ||||
if ($key == 'body') { | if ($key == 'body') { | ||||
continue; | continue; | ||||
} | } | ||||
if ($key == 'html-body') { | |||||
continue; | |||||
} | |||||
if ($key == 'headers') { | if ($key == 'headers') { | ||||
continue; | continue; | ||||
} | } | ||||
if ($key == 'attachments') { | if ($key == 'attachments') { | ||||
continue; | continue; | ||||
} | } | ||||
Show All 33 Lines | foreach ($messages as $message_key => $message) { | ||||
$info[] = '! '.coalesce($actor->getName(), $actor->getPHID()); | $info[] = '! '.coalesce($actor->getName(), $actor->getPHID()); | ||||
foreach ($actor->getUndeliverableReasons() as $reason) { | foreach ($actor->getUndeliverableReasons() as $reason) { | ||||
$info[] = ' - '.$reason; | $info[] = ' - '.$reason; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$info[] = null; | $info[] = null; | ||||
$info[] = pht('BODY'); | $info[] = pht('TEXT BODY'); | ||||
if (strlen($message->getBody())) { | |||||
$info[] = $message->getBody(); | $info[] = $message->getBody(); | ||||
} else { | |||||
$info[] = pht('(This message has no text body.)'); | |||||
} | |||||
$info[] = null; | |||||
$info[] = pht('HTML BODY'); | |||||
if (strlen($message->getHTMLBody())) { | |||||
$info[] = $message->getHTMLBody(); | |||||
$info[] = null; | |||||
} else { | |||||
$info[] = pht('(This message has no HTML body.)'); | |||||
} | |||||
$console->writeOut('%s', implode("\n", $info)); | $console->writeOut('%s', implode("\n", $info)); | ||||
if ($message_key != $last_key) { | if ($message_key != $last_key) { | ||||
$console->writeOut("\n%s\n\n", str_repeat('-', 80)); | $console->writeOut("\n%s\n\n", str_repeat('-', 80)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |