mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 11:42:42 +01:00
3400f24c8b
Summary: Fixes T12803. An install is having difficulty diagnosing mail failures, and one component is that permanent task failures aren't reaching the log. It's reasonable to send these to the log even when "phd.verbose" is off. See T12803 for a rough review of when we generate these failrues today. Test Plan: - Faked some exceptions. - Got a result in the log (P2058) with `phd.verbose` turned off. Reviewers: chad, amckinley Reviewed By: chad Maniphest Tasks: T12803 Differential Revision: https://secure.phabricator.com/D18106
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorMetaMTAWorker
|
|
extends PhabricatorWorker {
|
|
|
|
public function getMaximumRetryCount() {
|
|
return 250;
|
|
}
|
|
|
|
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
|
|
return ($task->getFailureCount() * 15);
|
|
}
|
|
|
|
protected function doWork() {
|
|
$message = $this->loadMessage();
|
|
|
|
if ($message->getStatus() != PhabricatorMailOutboundStatus::STATUS_QUEUE) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$message->sendNow();
|
|
} catch (PhabricatorMetaMTAPermanentFailureException $ex) {
|
|
// If the mailer fails permanently, fail this task permanently.
|
|
throw new PhabricatorWorkerPermanentFailureException($ex->getMessage());
|
|
}
|
|
}
|
|
|
|
private function loadMessage() {
|
|
$message_id = $this->getTaskData();
|
|
$message = id(new PhabricatorMetaMTAMail())
|
|
->load($message_id);
|
|
|
|
if (!$message) {
|
|
throw new PhabricatorWorkerPermanentFailureException(
|
|
pht(
|
|
'Unable to load mail message (with ID "%s") while preparing to '.
|
|
'deliver it.',
|
|
$message_id));
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
|
|
public function renderForDisplay(PhabricatorUser $viewer) {
|
|
return phutil_tag(
|
|
'pre',
|
|
array(
|
|
),
|
|
'phabricator/ $ ./bin/mail show-outbound --id '.$this->getTaskData());
|
|
}
|
|
|
|
}
|