1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 03:04:09 +02:00

Merge pull request #6779 from marc1706/ticket/17465

[ticket/17465] Add unit tests for handling of web push notifications
This commit is contained in:
Marc Alexander
2025-02-10 16:06:27 +01:00
committed by GitHub
3 changed files with 621 additions and 5 deletions

View File

@@ -133,11 +133,7 @@ class webpush
$notification_data = $this->get_anonymous_notifications();
}
// Decode and return data if everything is fine
$data = json_decode($notification_data, true);
$data['url'] = isset($data['url']) ? $this->path_helper->update_web_root_path($data['url']) : '';
return new JsonResponse($data);
return new JsonResponse($notification_data, 200, [], true);
}
/**
@@ -165,6 +161,11 @@ class webpush
$notification_data = $this->db->sql_fetchfield('push_data');
$this->db->sql_freeresult($result);
if (!$notification_data)
{
throw new http_exception(Response::HTTP_BAD_REQUEST, 'AJAX_ERROR_TEXT');
}
return $this->get_notification_data($notification_data);
}
@@ -192,6 +193,11 @@ class webpush
$notification_row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (!$notification_row || !isset($notification_row['push_data']) || !isset($notification_row['push_token']))
{
throw new http_exception(Response::HTTP_BAD_REQUEST, 'AJAX_ERROR_TEXT');
}
$notification_data = $notification_row['push_data'];
$push_token = $notification_row['push_token'];