diff --git a/phpBB/phpbb/notification/method/webpush.php b/phpBB/phpbb/notification/method/webpush.php index e3b39bfe70..9d19cb2200 100644 --- a/phpBB/phpbb/notification/method/webpush.php +++ b/phpBB/phpbb/notification/method/webpush.php @@ -140,7 +140,10 @@ class webpush extends messenger_base implements extended_method_interface { $data = $notification->get_insert_array(); $data += [ - 'push_data' => json_encode(array_merge($notification->get_insert_array(), ['notification_type_name' => $notification->get_type()])), + 'push_data' => json_encode(array_merge( + $data, + ['notification_type_name' => $notification->get_type()], + )), 'notification_time' => time(), 'push_token' => hash('sha256', random_bytes(32)) ]; @@ -345,6 +348,14 @@ class webpush extends messenger_base implements extended_method_interface return array_intersect_key($data, $row); } + /** + * Get template data for the UCP + * + * @param helper $controller_helper + * @param form_helper $form_helper + * + * @return array + */ public function get_ucp_template_data(helper $controller_helper, form_helper $form_helper): array { $subscription_map = $this->get_user_subscription_map([$this->user->id()]); diff --git a/phpBB/phpbb/ucp/controller/webpush.php b/phpBB/phpbb/ucp/controller/webpush.php index 27bd1dc049..313965db63 100644 --- a/phpBB/phpbb/ucp/controller/webpush.php +++ b/phpBB/phpbb/ucp/controller/webpush.php @@ -220,6 +220,13 @@ class webpush throw new http_exception(Response::HTTP_FORBIDDEN, 'NO_AUTH_OPERATION'); } + /** + * Get notification data for output from json encoded data stored in database + * + * @param string $notification_data Encoded data stored in database + * + * @return string Data for notification output with javascript + */ private function get_notification_data(string $notification_data): string { $row_data = json_decode($notification_data, true); @@ -255,7 +262,6 @@ class webpush */ public function worker(): Response { - // @todo: only work for logged in users, no anonymous & bot $content = $this->template->render('push_worker.js.twig', [ 'U_WEBPUSH_GET_NOTIFICATION' => $this->controller_helper->route('phpbb_ucp_push_get_notification_controller'), 'ASSETS_VERSION' => $this->config['assets_version'], @@ -273,20 +279,6 @@ class webpush return $response; } - /** - * Get template variables for subscribe type pages - * - * @return array - */ - protected function get_subscribe_vars(): array - { - return [ - 'U_WEBPUSH_SUBSCRIBE' => $this->controller_helper->route('phpbb_ucp_push_subscribe_controller'), - 'U_WEBPUSH_UNSUBSCRIBE' => $this->controller_helper->route('phpbb_ucp_push_unsubscribe_controller'), - 'FORM_TOKENS' => $this->form_helper->get_form_tokens(self::FORM_TOKEN_UCP), - ]; - } - /** * Check (un)subscribe form for valid link hash *