mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[ticket/17339] Support receiving push notifications if not logged in
PHPBB-17339
This commit is contained in:
@@ -51,6 +51,9 @@ class webpush extends messenger_base implements extended_method_interface
|
||||
/** @var int Fallback size for padding if endpoint is mozilla, see https://github.com/web-push-libs/web-push-php/issues/108#issuecomment-2133477054 */
|
||||
const MOZILLA_FALLBACK_PADDING = 2820;
|
||||
|
||||
/** @var array Map for storing push token between db insertion and sending of notifications */
|
||||
private array $push_token_map = [];
|
||||
|
||||
/**
|
||||
* Notification Method Web Push constructor
|
||||
*
|
||||
@@ -145,9 +148,11 @@ class webpush extends messenger_base implements extended_method_interface
|
||||
'avatar' => $notification->get_avatar(),
|
||||
]),
|
||||
'notification_time' => time(),
|
||||
'push_token' => hash('sha256', random_bytes(32))
|
||||
];
|
||||
$data = self::clean_data($data);
|
||||
$insert_buffer->insert($data);
|
||||
$this->push_token_map[$notification->notification_type_id][$notification->item_id] = $data['push_token'];
|
||||
}
|
||||
|
||||
$insert_buffer->flush();
|
||||
@@ -221,7 +226,9 @@ class webpush extends messenger_base implements extended_method_interface
|
||||
$data = [
|
||||
'item_id' => $notification->item_id,
|
||||
'type_id' => $notification->notification_type_id,
|
||||
'user_id' => $notification->user_id,
|
||||
'version' => $this->config['assets_version'],
|
||||
'token' => hash('sha256', $user['user_form_salt'] . $this->push_token_map[$notification->notification_type_id][$notification->item_id]),
|
||||
];
|
||||
$json_data = json_encode($data);
|
||||
|
||||
@@ -337,6 +344,7 @@ class webpush extends messenger_base implements extended_method_interface
|
||||
'item_parent_id' => null,
|
||||
'user_id' => null,
|
||||
'push_data' => null,
|
||||
'push_token' => null,
|
||||
'notification_time' => null,
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user