Skip to content

Commit f1eb89a

Browse files
committed
Merge branch 'main' into Release-1.0.0
Signed-off-by: Matt Friedman <maf675@gmail.com> # Conflicts: # CHANGELOG.md # composer.json
2 parents e36efb5 + 7ffb021 commit f1eb89a

25 files changed

+720
-87
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ jobs:
125125
db: "mysql:5.7"
126126
- php: '8.3'
127127
db: "mysql:5.7"
128+
- php: '8.4'
129+
db: "mysql:5.7"
128130

129131
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
130132

@@ -247,6 +249,8 @@ jobs:
247249
db: "postgres:14"
248250
- php: '8.3'
249251
db: "postgres:14"
252+
- php: '8.4'
253+
db: "postgres:14"
250254

251255
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
252256

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# Changelog
22

3-
### 1.0.0 - 2024-06-16
3+
### 1.0.0 - 2024-07-01
44

55
- First official release.
66

7+
### 1.0.0-RC10 - 2024-07-01
8+
9+
- Apple mobile devices are now supported through the implementation of progressive web app capabilities.
10+
- Notifications are now sent in the recipient’s preferred board language.
11+
- Re-worded and redesigned the enable/subscribe push notification buttons:
12+
- In the UCP, the enable/subscribe button clearly indicates its state.
13+
- The enable/subscribe toggle in the notification dropdown is now hidden if subscribing is not supported.
14+
- Added a warning message in the ACP for boards on servers that are not compatible with push notifications.
15+
716
### 1.0.0-RC9 - 2024-06-16
817

918
- The subscribe toggle in the notification dropdown has been optimized for better mobile usability.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ Testing push notifications necessitates user-to-user interactions to observe the
3737

3838
1. **User Account Setup:**
3939
- Create at least two distinct user accounts for testing purposes.
40-
- In user1's account notifications preferences, assign web push notifications and subscribe to receive Push Notifications.
40+
- In the notifications preferences for _**User Account 1**_, subscribe to receive Push Notifications (and assign web push notification types if necessary).
4141

4242
2. **Message, Quote, or Reply Interaction:**
43-
- Initiate a user-to-user interaction by performing one of the following actions using "User Account 2":
44-
- **Private Message:** Send a direct message from "User Account 2" to "User Account 1".
45-
- **Quote:** Quote a post or message authored by "User Account 1" using "User Account 2".
46-
- **Reply:** Respond to a post or message authored by "User Account 1" using "User Account 2".
43+
- Initiate a user-to-user interaction by performing one of the following actions using _**User Account 2**_:
44+
- **Private Message:** Send a direct message from _**User Account 2**_ to _**User Account 1**_.
45+
- **Quote:** Quote a post or message authored by _**User Account 1**_ using _**User Account 2**_.
46+
- **Reply:** Respond to a post or message authored by _**User Account 1**_ using _**User Account 2**_.
4747

4848
3. **Observing Push Notifications:**
49-
- Once the interaction is performed from "User Account 2" to engage with "User Account 1," you promptly should see a notification for "User Account 1."
49+
- Once the interaction is performed from _**User Account 2**_ to engage with _**User Account 1**_, you promptly should see a notification for _**User Account 1**_.
5050

5151
4. **Caveats for Local Testing**
5252
- Local testing of Push Notifications only works from a `localhost` address or if your local server has a secure SSL certificate.

acp/wpn_acp_module.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ public function display_settings()
105105
'S_WEBPUSH_METHOD_ENABLED' => $this->config['wpn_webpush_method_enabled'],
106106
'U_ACTION' => $this->u_action,
107107
]);
108+
109+
if (!$this->request->server('HTTPS', false) && $this->request->server('SERVER_NAME') !== 'localhost')
110+
{
111+
$this->errors[] = $this->lang->lang('WEBPUSH_INSECURE_SERVER_ERROR');
112+
}
113+
114+
$this->display_errors();
108115
}
109116

110117
/**
@@ -135,13 +142,8 @@ public function save_settings()
135142
validate_config_vars($display_settings, $config_array, $this->errors);
136143
}
137144

138-
if (count($this->errors))
145+
if ($this->display_errors())
139146
{
140-
$this->template->assign_vars([
141-
'S_ERROR' => (bool) count($this->errors),
142-
'ERROR_MSG' => implode('<br>', $this->errors),
143-
]);
144-
145147
return;
146148
}
147149

@@ -154,4 +156,21 @@ public function save_settings()
154156

155157
trigger_error($this->lang->lang('CONFIG_UPDATED') . adm_back_link($this->u_action), E_USER_NOTICE);
156158
}
159+
160+
/**
161+
* Display any errors
162+
*
163+
* @return bool
164+
*/
165+
public function display_errors()
166+
{
167+
$has_errors = (bool) count($this->errors);
168+
169+
$this->template->assign_vars([
170+
'S_ERROR' => $has_errors,
171+
'ERROR_MSG' => $has_errors ? implode('<br>', $this->errors) : '',
172+
]);
173+
174+
return $has_errors;
175+
}
157176
}

config/routing.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
phpbb_webpushnotifications_ucp_routing:
22
resource: wpn_ucp.yml
33
prefix: /user
4+
5+
phpbb_webpushnotifications_manifest_controller:
6+
path: /manifest
7+
defaults: { _controller: phpbb.wpn.controller.manifest:handle }

config/services.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ services:
1212
phpbb.wpn.listener:
1313
class: phpbb\webpushnotifications\event\listener
1414
arguments:
15+
- '@config'
1516
- '@controller.helper'
17+
- '@upload_imagesize'
1618
- '@phpbb.wpn.form_helper'
1719
- '@language'
1820
- '@template'
1921
- '@notification_manager'
22+
- '%core.root_path%'
2023
tags:
2124
- { name: event.listener }
2225

@@ -26,6 +29,7 @@ services:
2629
arguments:
2730
- '@config'
2831
- '@dbal.conn'
32+
- '@language'
2933
- '@log'
3034
- '@user_loader'
3135
- '@user'
@@ -51,3 +55,10 @@ services:
5155
- '%tables.phpbb.wpn.notification_push%'
5256
- '%tables.phpbb.wpn.push_subscriptions%'
5357

58+
phpbb.wpn.controller.manifest:
59+
class: phpbb\webpushnotifications\controller\manifest
60+
arguments:
61+
- '@config'
62+
- '@language'
63+
- '@path_helper'
64+
- '@user'

controller/manifest.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2024, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
namespace phpbb\webpushnotifications\controller;
12+
13+
use phpbb\config\config;
14+
use phpbb\exception\http_exception;
15+
use phpbb\language\language;
16+
use phpbb\path_helper;
17+
use phpbb\user;
18+
use Symfony\Component\HttpFoundation\JsonResponse;
19+
use Symfony\Component\HttpFoundation\Response;
20+
21+
class manifest
22+
{
23+
/** @var config */
24+
protected $config;
25+
26+
/** @var language */
27+
protected $language;
28+
29+
/** @var path_helper */
30+
protected $path_helper;
31+
32+
/** @var user */
33+
protected $user;
34+
35+
/**
36+
* Constructor for webpush controller
37+
*
38+
* @param config $config
39+
* @param path_helper $path_helper
40+
* @param language $language
41+
* @param user $user
42+
*/
43+
public function __construct(config $config, language $language, path_helper $path_helper, user $user)
44+
{
45+
$this->config = $config;
46+
$this->path_helper = $path_helper;
47+
$this->language = $language;
48+
$this->user = $user;
49+
}
50+
51+
/**
52+
* Handle creation of a manifest json file for progressive web-app support
53+
*
54+
* @return JsonResponse
55+
*/
56+
public function handle(): JsonResponse
57+
{
58+
if ($this->user->data['is_bot'] || $this->user->data['user_type'] == USER_INACTIVE)
59+
{
60+
throw new http_exception(Response::HTTP_FORBIDDEN, 'Forbidden');
61+
}
62+
63+
$board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
64+
65+
$manifest = [
66+
'name' => $this->config['sitename'],
67+
'short_name' => $this->config['pwa_short_name'] ?: substr($this->config['sitename'], 0, 12),
68+
'display' => 'standalone',
69+
'orientation' => 'portrait',
70+
'dir' => $this->language->lang('DIRECTION'),
71+
'start_url' => $board_path,
72+
'scope' => $board_path,
73+
];
74+
75+
if (!empty($this->config['pwa_icon_small']) && !empty($this->config['pwa_icon_large']))
76+
{
77+
$manifest['icons'] = [
78+
[
79+
'src' => $this->config['icons_path'] . '/' . $this->config['pwa_icon_small'],
80+
'sizes' => '192x192',
81+
'type' => 'image/png'
82+
],
83+
[
84+
'src' => $this->config['icons_path'] . '/' . $this->config['pwa_icon_large'],
85+
'sizes' => '512x512',
86+
'type' => 'image/png'
87+
]
88+
];
89+
}
90+
91+
return new JsonResponse($manifest);
92+
}
93+
}

0 commit comments

Comments
 (0)