mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 10:52:41 +01:00
4b0ef353e4
Summary: Fixes T4202. We have old code in MetaMTA which implements gradual backoff and maximum retries. However, we have more general code in the task queue which does this, too. We can just use the more general stuff in the task queue; it obsoletes the specific stuff in MetaMTA, which is more complex and ran into some kind of issue in T4202. Remove `retryCount`, `nextRetry` (obsoleted by task queue retry mechanisms) and "simulated failures" (no longer in use). Generally, modern infrastructure has replaced these mechanisms with more general ones. Test Plan: - Sent mail. - Observed unsendable mail failing in reasonable ways in the queue. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4202 Differential Revision: https://secure.phabricator.com/D8115
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorMetaMTAWorker
|
|
extends PhabricatorWorker {
|
|
|
|
public function getMaximumRetryCount() {
|
|
return 250;
|
|
}
|
|
|
|
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
|
|
return ($task->getFailureCount() * 15);
|
|
}
|
|
|
|
public function doWork() {
|
|
$message = $this->loadMessage();
|
|
if (!$message) {
|
|
throw new PhabricatorWorkerPermanentFailureException(
|
|
pht('Unable to load message!'));
|
|
}
|
|
|
|
if ($message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) {
|
|
return;
|
|
}
|
|
|
|
$id = $message->getID();
|
|
$message->sendNow();
|
|
|
|
// task failed if the message is still queued
|
|
// (instead of sent, void, or failed)
|
|
if ($message->getStatus() == PhabricatorMetaMTAMail::STATUS_QUEUE) {
|
|
throw new Exception(
|
|
pht('Failed to send message.'));
|
|
}
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
}
|