1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/17010] Queue notifications and use flush to send them

PHPBB3-17010
This commit is contained in:
Marc Alexander
2022-09-19 20:34:42 +02:00
parent be21479b2a
commit af29f388da

View File

@@ -185,6 +185,7 @@ class webpush extends \phpbb\notification\method\messenger_base
$web_push = new \Minishlink\WebPush\WebPush($auth);
$number_of_notifications = 0;
// Time to go through the queue and send emails
/** @var type_interface $notification */
foreach ($this->queue as $notification)
@@ -222,9 +223,8 @@ class webpush extends \phpbb\notification\method\messenger_base
],
'contentEncoding' => !empty($subscription['encoding']) ? $subscription['encoding'] : null,
]);
//$web_push->queueNotification($push_subscription, $json_data);
$foo = $web_push->sendOneNotification($push_subscription, $json_data);
$meh = 2;
$web_push->queueNotification($push_subscription, $json_data);
$number_of_notifications++;
}
catch (\ErrorException $exception)
{
@@ -235,6 +235,21 @@ class webpush extends \phpbb\notification\method\messenger_base
}
// @todo: Try offloading to after request
try
{
foreach ($web_push->flush($number_of_notifications) as $report)
{
if (!$report->isSuccess())
{
// @todo: log errors / remove subscription
}
}
}
catch (\ErrorException $exception)
{
// @todo: write to log
}
// We're done, empty the queue
$this->empty_queue();