[ticket/17010] Clean up code and remove unused method

PHPBB3-17010
This commit is contained in:
Marc Alexander 2023-11-05 15:15:11 +01:00
parent a86d222ab0
commit adf639e871
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -113,9 +113,9 @@ class webpush
$sql = 'SELECT push_data
FROM ' . $this->notification_webpush_table . '
WHERE user_id = ' . $this->user->id() . '
AND notification_type_id = ' . $type_id . '
AND item_id = ' . $item_id;
WHERE user_id = ' . (int) $this->user->id() . '
AND notification_type_id = ' . (int) $type_id . '
AND item_id = ' . (int) $item_id;
$result = $this->db->sql_query($sql);
$notification_data = $this->db->sql_fetchfield('push_data');
$this->db->sql_freeresult($result);
@ -229,8 +229,8 @@ class webpush
$endpoint = $data['endpoint'];
$sql = 'DELETE FROM ' . $this->push_subscriptions_table . '
WHERE user_id = ' . $this->user->id() . "
AND endpoint = '" . $this->db->sql_escape($endpoint) . "'";
WHERE user_id = ' . (int) $this->user->id() . "
AND endpoint = '" . (int) $this->db->sql_escape($endpoint) . "'";
$this->db->sql_query($sql);
return new JsonResponse([
@ -238,26 +238,4 @@ class webpush
'form_tokens' => $this->form_helper->get_form_tokens(self::FORM_TOKEN_UCP),
]);
}
/**
* Get subscriptions for current user
*
* @return array Subscriptions for user
*/
protected function get_subscriptions(): array
{
$subscriptions = [];
$sql = 'SELECT endpoint, expiration_time
FROM ' . $this->push_subscriptions_table . '
WHERE user_id = ' . $this->user->id();
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$subscriptions[] = $row;
}
$this->db->sql_freeresult($result);
return $subscriptions;
}
}