From 73a06ef4df3d941eecaae42764e252939988d14b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 1 Oct 2024 21:33:57 +0200 Subject: [PATCH] [ticket/17343] Fix emoji display and load users for notification text PHPBB-17343 --- .../config/default/container/services_ucp.yml | 1 + phpBB/phpbb/ucp/controller/webpush.php | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/phpBB/config/default/container/services_ucp.yml b/phpBB/config/default/container/services_ucp.yml index 046c342f25..acd78f8440 100644 --- a/phpBB/config/default/container/services_ucp.yml +++ b/phpBB/config/default/container/services_ucp.yml @@ -38,6 +38,7 @@ services: - '@notification_manager' - '@path_helper' - '@request' + - '@user_loader' - '@user' - '@template.twig.environment' - '%tables.notification_push%' diff --git a/phpBB/phpbb/ucp/controller/webpush.php b/phpBB/phpbb/ucp/controller/webpush.php index 56a6cc61f6..27bd1dc049 100644 --- a/phpBB/phpbb/ucp/controller/webpush.php +++ b/phpBB/phpbb/ucp/controller/webpush.php @@ -25,6 +25,7 @@ use phpbb\path_helper; use phpbb\request\request_interface; use phpbb\symfony_request; use phpbb\user; +use phpbb\user_loader; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; @@ -61,6 +62,9 @@ class webpush /** @var request_interface */ protected $request; + /** @var user_loader */ + protected $user_loader; + /** @var user */ protected $user; @@ -84,13 +88,14 @@ class webpush * @param manager $notification_manager * @param path_helper $path_helper * @param request_interface $request + * @param user_loader $user_loader * @param user $user * @param Environment $template * @param string $notification_webpush_table * @param string $push_subscriptions_table */ public function __construct(config $config, controller_helper $controller_helper, driver_interface $db, form_helper $form_helper, language $language, manager $notification_manager, - path_helper $path_helper, request_interface $request, user $user, Environment $template, string $notification_webpush_table, string $push_subscriptions_table) + path_helper $path_helper, request_interface $request, user_loader $user_loader, user $user, Environment $template, string $notification_webpush_table, string $push_subscriptions_table) { $this->config = $config; $this->controller_helper = $controller_helper; @@ -100,6 +105,7 @@ class webpush $this->notification_manager = $notification_manager; $this->path_helper = $path_helper; $this->request = $request; + $this->user_loader = $user_loader; $this->user = $user; $this->template = $template; $this->notification_webpush_table = $notification_webpush_table; @@ -227,15 +233,16 @@ class webpush // Get notification from row_data $notification = $this->notification_manager->get_item_type_class($row_data['notification_type_name'], $row_data); - $notification_data = [ + // Load users for notification + $this->user_loader->load_users($notification->users_to_query()); + + return json_encode([ 'heading' => $this->config['sitename'], - 'title' => strip_tags($notification->get_title()), - 'text' => strip_tags($notification->get_reference()), + 'title' => strip_tags(html_entity_decode($notification->get_title(), ENT_NOQUOTES, 'UTF-8')), + 'text' => strip_tags(html_entity_decode($notification->get_reference(), ENT_NOQUOTES, 'UTF-8')), 'url' => htmlspecialchars_decode($notification->get_url()), 'avatar' => $notification->get_avatar(), - ]; - - return json_encode($notification_data); + ]); } /**