mirror of
https://github.com/phpbb/phpbb.git
synced 2025-10-05 20:21:53 +02:00
[ticket/17451] Prevent web push service worker from updating user activity
PHPBB-17451
This commit is contained in:
@@ -1715,7 +1715,7 @@ class session
|
|||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if (isset($this->data['session_time'], $this->data['user_id']))
|
if (isset($this->data['session_time'], $this->data['user_id']) && !$this->is_push_notification_request())
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET user_lastvisit = ' . (int) $this->data['session_time'] . ',
|
SET user_lastvisit = ' . (int) $this->data['session_time'] . ',
|
||||||
@@ -1734,7 +1734,7 @@ class session
|
|||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if (isset($this->time_now, $this->data['user_id']))
|
if (isset($this->time_now, $this->data['user_id']) && !$this->is_push_notification_request())
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET user_last_active = ' . $this->time_now . '
|
SET user_last_active = ' . $this->time_now . '
|
||||||
@@ -1742,4 +1742,16 @@ class session
|
|||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the request is an Ajax request from the web push service worker
|
||||||
|
*
|
||||||
|
* @return bool True if the request is an Ajax request and the page URL contains '/push/notification', otherwise false
|
||||||
|
*/
|
||||||
|
protected function is_push_notification_request(): bool
|
||||||
|
{
|
||||||
|
global $request;
|
||||||
|
|
||||||
|
return $request->is_ajax() && str_contains($this->page['page'], '/push/notification');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user