Retry failed mails with the defer() feature

This commit is contained in:
Matthew Exon 2021-06-12 18:22:53 +02:00
parent a50ca54999
commit 6596a81af1

View file

@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
@ -121,9 +122,10 @@ function mailstream_send_hook(&$a, $data)
}
if (!mailstream_send($data['message_id'], $item, $user)) {
$delayed = date(DateTimeFormat::utc('now + 1 hour'));
$data['tries'] += 1;
Hook::fork(['priority' => PRIORITY_LOW, 'delayed' => $delayed], 'mailstream_send_hook', $data);
Logger::debug('mailstream_send_hook send failed, will retry', $data);
if (!Worker::defer()) {
Logger::error('mailstream_send_hook failed and could not defer', $data);
}
}
}