[ticket/17343] Fix emoji display and load users for notification text

PHPBB-17343
This commit is contained in:
Marc Alexander 2024-10-01 21:33:57 +02:00
parent 767d9e1198
commit 73a06ef4df
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 15 additions and 7 deletions

View file

@ -38,6 +38,7 @@ services:
- '@notification_manager'
- '@path_helper'
- '@request'
- '@user_loader'
- '@user'
- '@template.twig.environment'
- '%tables.notification_push%'

View file

@ -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);
]);
}
/**