1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-03 04:02:43 +01:00
phorge-phorge/src/applications/metamta/PhabricatorMetaMTAWorker.php
Joshua Spence 94b96ae533 Fix visibility of the PhabricatorWorker::doWork() methods
Summary: Ref T6822. This method is only called from within the `PhabricatorWorker::executeTask()` and `PhabricatorWorker::scheduleTask()` methods.

Test Plan: `grep`ped for `->doWork`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11406
2015-01-16 06:58:50 +11:00

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() != PhabricatorMetaMTAMail::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());
}
}