Skip to content

Commit 0760621

Browse files
committed
Show usernames correctly in push notifications
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 965c753 commit 0760621

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ services:
5252
- '@notification_manager'
5353
- '@path_helper'
5454
- '@request'
55+
- '@user_loader'
5556
- '@user'
5657
- '@template.twig.environment'
5758
- '%tables.phpbb.wpn.notification_push%'

ucp/controller/webpush.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use phpbb\request\request_interface;
2323
use phpbb\symfony_request;
2424
use phpbb\user;
25+
use phpbb\user_loader;
2526
use Symfony\Component\HttpFoundation\JsonResponse;
2627
use Symfony\Component\HttpFoundation\Response;
2728
use Twig\Environment;
@@ -58,6 +59,9 @@ class webpush
5859
/** @var request_interface */
5960
protected $request;
6061

62+
/** @var user_loader */
63+
protected $user_loader;
64+
6165
/** @var user */
6266
protected $user;
6367

@@ -81,13 +85,14 @@ class webpush
8185
* @param manager $notification_manager
8286
* @param path_helper $path_helper
8387
* @param request_interface $request
88+
* @param user_loader $user_loader
8489
* @param user $user
8590
* @param Environment $template
8691
* @param string $notification_webpush_table
8792
* @param string $push_subscriptions_table
8893
*/
8994
public function __construct(config $config, controller_helper $controller_helper, driver_interface $db, form_helper $form_helper, language $language, manager $notification_manager,
90-
path_helper $path_helper, request_interface $request, user $user, Environment $template, string $notification_webpush_table, string $push_subscriptions_table)
95+
path_helper $path_helper, request_interface $request, user_loader $user_loader, user $user, Environment $template, string $notification_webpush_table, string $push_subscriptions_table)
9196
{
9297
$this->config = $config;
9398
$this->controller_helper = $controller_helper;
@@ -97,6 +102,7 @@ public function __construct(config $config, controller_helper $controller_helper
97102
$this->notification_manager = $notification_manager;
98103
$this->path_helper = $path_helper;
99104
$this->request = $request;
105+
$this->user_loader = $user_loader;
100106
$this->user = $user;
101107
$this->template = $template;
102108
$this->notification_webpush_table = $notification_webpush_table;
@@ -223,6 +229,9 @@ private function get_notification_data(string $notification_data): string
223229
// Get notification from row_data
224230
$notification = $this->notification_manager->get_item_type_class($row_data['notification_type_name'], $row_data);
225231

232+
// Load users for notification
233+
$this->user_loader->load_users($notification->users_to_query());
234+
226235
return json_encode([
227236
'heading' => $this->config['sitename'],
228237
'title' => strip_tags($notification->get_title()),

0 commit comments

Comments
 (0)