Skip to content

Commit 92fbc48

Browse files
committed
Merge branch 'main' into Release-1.0.0
2 parents 160d39a + ad9bb9e commit 92fbc48

File tree

7 files changed

+81
-17
lines changed

7 files changed

+81
-17
lines changed

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 each user account's notifications preferences, assign web push notifications and subscribe to them to receive Push Notifications.
40+
- In user1's account notifications preferences, assign web push notifications and subscribe to receive Push Notifications.
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 1":
44-
- **Private Message:** Send a direct message from "User Account 1" to "User Account 2".
45-
- **Quote:** Quote a post or message authored by "User Account 2" using "User Account 1".
46-
- **Reply:** Respond to a post or message authored by "User Account 2" using "User Account 1".
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 1" to engage with "User Account 2," you promptly should see a notification for "User Account 2."
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.

ext.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ public function is_enableable()
3939
*/
4040
protected function check_phpbb_version()
4141
{
42-
if (phpbb_version_compare(PHPBB_VERSION, '3.3.12-dev', '<') ||
43-
phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>='))
42+
if (phpbb_version_compare(PHPBB_VERSION, '3.3.12', '<'))
4443
{
45-
$this->errors[] = 'PHPBB_VERSION_ERROR';
44+
$this->errors[] = 'PHPBB_VERSION_MIN_ERROR';
45+
}
46+
47+
if (phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>='))
48+
{
49+
$this->errors[] = 'PHPBB_VERSION_MAX_ERROR';
4650
}
4751

4852
return $this;

language/en/install.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
//
3939

4040
$lang = array_merge($lang, [
41-
'PHPBB_VERSION_ERROR' => 'This extension is not compatible with your board. You must be using phpBB 3.3.12 or newer, up to but not including phpBB 4.x.x.',
42-
'PHP_VERSION_ERROR' => 'This extension is not compatible with your server. Your server must be running PHP 7.3 or newer.',
41+
'PHPBB_VERSION_MAX_ERROR' => 'This extension can not be installed on your board. You are using phpBB 4, which already contains the features in this extension.',
42+
'PHPBB_VERSION_MIN_ERROR' => 'This extension is not compatible with your board. You must be using phpBB 3.3.12 or newer.',
43+
'PHP_VERSION_ERROR' => 'This extension is not compatible with your server. Your server must be running PHP 7.3 or newer.',
4344
]);

language/ru/install.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
//
3939

4040
$lang = array_merge($lang, [
41-
'PHPBB_VERSION_ERROR' => 'Данное расширение несовместимо с установленной версией конференции. Необходима версия phpBB 3.3.12 или выше, за исключением phpBB 4.x.x.',
42-
'PHP_VERSION_ERROR' => 'Данное расширение несовместимо с установленной на сервере версией PHP. Необходима версия PHP 7.3 или выше.',
41+
'PHPBB_VERSION_MAX_ERROR' => 'Данное расширение несовместимо с установленной версией конференции. Вы используете версию phpBB 4, которая уже содержит соответствующие функции.',
42+
'PHPBB_VERSION_MIN_ERROR' => 'Данное расширение несовместимо с установленной версией конференции. Необходима версия phpBB 3.3.12 или выше.',
43+
'PHP_VERSION_ERROR' => 'Данное расширение несовместимо с установленной на сервере версией PHP. Необходима версия PHP 7.3 или выше.',
4344
]);

notification/method/webpush.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class webpush extends messenger_base implements extended_method_interface
5252
protected $push_subscriptions_table;
5353

5454
/** @var int Fallback size for padding if endpoint is mozilla, see https://github.com/web-push-libs/web-push-php/issues/108#issuecomment-2133477054 */
55-
const MOZILLA_FALLBACK_PADDING = 2820;
55+
public const MOZILLA_FALLBACK_PADDING = 2820;
5656

5757
/**
5858
* Notification Method Web Push constructor
@@ -216,7 +216,7 @@ protected function notify_using_webpush(): void
216216

217217
$user_subscriptions = $user_subscription_map[$notification->user_id] ?? [];
218218

219-
if ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL
219+
if (($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL)
220220
|| empty($user_subscriptions))
221221
{
222222
continue;
@@ -495,13 +495,19 @@ protected function get_board_url()
495495
* @param string $endpoint
496496
*
497497
* @return void
498-
* @throws \Exception
499498
*/
500499
protected function set_endpoint_padding(\Minishlink\WebPush\WebPush $web_push, string $endpoint): void
501500
{
502501
if (strpos($endpoint, 'mozilla.com') || strpos($endpoint, 'mozaws.net'))
503502
{
504-
$web_push->setAutomaticPadding(self::MOZILLA_FALLBACK_PADDING);
503+
try
504+
{
505+
$web_push->setAutomaticPadding(self::MOZILLA_FALLBACK_PADDING);
506+
}
507+
catch (\Exception $e)
508+
{
509+
// This shouldn't happen since we won't pass padding length outside limits
510+
}
505511
}
506512
}
507513
}

styles/all/theme/phpbb_wpn.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,19 @@
1919
flex-wrap: nowrap;
2020
justify-content: space-between;
2121
padding: 5px 10px;
22+
gap: 20px;
2223
}
2324

2425
.wpn-notification-dropdown-footer button:disabled {
2526
opacity: 0.7;
2627
}
28+
29+
@media only screen and (max-width: 550px), only screen and (max-device-width: 550px) {
30+
.wpn-notification-dropdown-footer button > span {
31+
display: none;
32+
}
33+
34+
.wpn-notification-dropdown-footer button > .icon {
35+
font-size: 24px;
36+
}
37+
}

tests/notification/notification_method_webpush_test.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,47 @@ public function test_prune_notifications($notification_type, $post_data, $expect
651651
$this->assertCount(0, $cur_notifications, 'Assert that no notifications have been pruned');
652652
}
653653

654+
public function data_set_endpoint_padding(): array
655+
{
656+
return [
657+
[
658+
'foo.mozilla.com',
659+
webpush::MOZILLA_FALLBACK_PADDING
660+
],
661+
[
662+
'foo.mozaws.net',
663+
webpush::MOZILLA_FALLBACK_PADDING
664+
],
665+
[
666+
'foo.android.googleapis.com',
667+
\Minishlink\WebPush\Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH,
668+
],
669+
];
670+
}
671+
672+
/**
673+
* @dataProvider data_set_endpoint_padding
674+
*/
675+
public function test_set_endpoint_padding($endpoint, $expected_padding): void
676+
{
677+
$web_push_reflection = new \ReflectionMethod($this->notification_method_webpush, 'set_endpoint_padding');
678+
$web_push_reflection->setAccessible(true);
679+
680+
$auth = [
681+
'VAPID' => [
682+
'subject' => generate_board_url(),
683+
'publicKey' => $this->config['wpn_webpush_vapid_public'],
684+
'privateKey' => $this->config['wpn_webpush_vapid_private'],
685+
],
686+
];
687+
688+
$web_push = new \Minishlink\WebPush\WebPush($auth);
689+
690+
$this->assertEquals(\Minishlink\WebPush\Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH, $web_push->getAutomaticPadding());
691+
$web_push_reflection->invoke($this->notification_method_webpush, $web_push, $endpoint);
692+
$this->assertEquals($expected_padding, $web_push->getAutomaticPadding());
693+
}
694+
654695
protected function create_subscription_for_user($user_id, bool $invalidate_endpoint = false): array
655696
{
656697
$client = new \GuzzleHttp\Client();

0 commit comments

Comments
 (0)