mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-28 15:53:17 +00:00
Retry failed mails with the defer() feature
This commit is contained in:
parent
a50ca54999
commit
6596a81af1
1 changed files with 5 additions and 3 deletions
|
@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -121,9 +122,10 @@ function mailstream_send_hook(&$a, $data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mailstream_send($data['message_id'], $item, $user)) {
|
if (!mailstream_send($data['message_id'], $item, $user)) {
|
||||||
$delayed = date(DateTimeFormat::utc('now + 1 hour'));
|
Logger::debug('mailstream_send_hook send failed, will retry', $data);
|
||||||
$data['tries'] += 1;
|
if (!Worker::defer()) {
|
||||||
Hook::fork(['priority' => PRIORITY_LOW, 'delayed' => $delayed], 'mailstream_send_hook', $data);
|
Logger::error('mailstream_send_hook failed and could not defer', $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue