mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +01:00
3b987a93ce
Summary: Ref T5791. This collects outbound mail status in one place and makes the list view a little spiffier. Test Plan: Looked at list and detail views. Grepped for changed classes/constants. Reviewers: chad Reviewed By: chad Maniphest Tasks: T5791 Differential Revision: https://secure.phabricator.com/D13884
46 lines
1.1 KiB
PHP
46 lines
1.1 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) {
|
|
throw new PhabricatorWorkerPermanentFailureException(
|
|
pht('Unable to load message!'));
|
|
}
|
|
|
|
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();
|
|
return id(new PhabricatorMetaMTAMail())->load($message_id);
|
|
}
|
|
|
|
public function renderForDisplay(PhabricatorUser $viewer) {
|
|
return phutil_tag(
|
|
'pre',
|
|
array(
|
|
),
|
|
'phabricator/ $ ./bin/mail show-outbound --id '.$this->getTaskData());
|
|
}
|
|
|
|
}
|