- // we use the push variable also as a counter, if we failed we
- // increment this until some upper limit where we give up
- $retrial = $subscriber['push'];
-
- if ($retrial > 14) {
- dba::update('push_subscriber', ['push' => 0, 'next_try' => NULL_DATE], $condition);
- logger('Delivery error: Giving up for ' . $subscriber['callback_url'], LOGGER_DEBUG);
- } else {
- // Calculate the delay until the next trial
- $delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1));
- $next = DateTimeFormat::utc('now + ' . $delay . ' seconds');
-
- $retrial = $retrial + 1;
-
- dba::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], $condition);
- logger('Delivery error: Next try (' . $retrial . ') for ' . $subscriber['callback_url'] . ' at ' . $next, LOGGER_DEBUG);
- }