2012-02-28 02:11:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorMetaMTAWorker
|
|
|
|
extends PhabricatorWorker {
|
|
|
|
|
2014-02-01 23:35:42 +01:00
|
|
|
public function getMaximumRetryCount() {
|
|
|
|
return 250;
|
|
|
|
}
|
2012-02-28 02:11:25 +01:00
|
|
|
|
2012-11-01 19:30:23 +01:00
|
|
|
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
|
2014-02-01 23:35:42 +01:00
|
|
|
return ($task->getFailureCount() * 15);
|
2012-02-28 02:11:25 +01:00
|
|
|
}
|
|
|
|
|
2015-01-15 20:58:49 +01:00
|
|
|
protected function doWork() {
|
2012-11-02 00:38:47 +01:00
|
|
|
$message = $this->loadMessage();
|
2014-02-01 23:35:42 +01:00
|
|
|
if (!$message) {
|
|
|
|
throw new PhabricatorWorkerPermanentFailureException(
|
|
|
|
pht('Unable to load message!'));
|
|
|
|
}
|
|
|
|
|
2015-08-14 13:31:42 +02:00
|
|
|
if ($message->getStatus() != PhabricatorMailOutboundStatus::STATUS_QUEUE) {
|
2012-02-28 02:11:25 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-02-01 23:35:42 +01:00
|
|
|
|
2014-04-22 00:45:29 +02:00
|
|
|
try {
|
|
|
|
$message->sendNow();
|
|
|
|
} catch (PhabricatorMetaMTAPermanentFailureException $ex) {
|
|
|
|
// If the mailer fails permanently, fail this task permanently.
|
|
|
|
throw new PhabricatorWorkerPermanentFailureException($ex->getMessage());
|
2012-02-28 02:11:25 +01:00
|
|
|
}
|
|
|
|
}
|
2012-11-02 00:38:47 +01:00
|
|
|
|
|
|
|
private function loadMessage() {
|
2014-02-01 23:35:42 +01:00
|
|
|
$message_id = $this->getTaskData();
|
|
|
|
return id(new PhabricatorMetaMTAMail())->load($message_id);
|
2012-11-02 00:38:47 +01:00
|
|
|
}
|
|
|
|
|
2013-12-21 03:02:32 +01:00
|
|
|
public function renderForDisplay(PhabricatorUser $viewer) {
|
2013-01-18 03:43:35 +01:00
|
|
|
return phutil_tag(
|
2013-08-30 02:37:17 +02:00
|
|
|
'pre',
|
|
|
|
array(
|
|
|
|
),
|
|
|
|
'phabricator/ $ ./bin/mail show-outbound --id '.$this->getTaskData());
|
2012-12-18 02:12:55 +01:00
|
|
|
}
|
|
|
|
|
2012-02-28 02:11:25 +01:00
|
|
|
}
|