fix: filter FCM sends by notifications_enabled preference

This commit is contained in:
2026-06-13 17:48:53 -04:00
parent 19fc37c1f3
commit 52947f7b21
2 changed files with 23 additions and 1 deletions

View File

@@ -54,6 +54,12 @@ class FCMService
{
if (!$this->isConfigured()) return false;
$enabled = $this->db->fetch(
'SELECT notifications_enabled FROM users WHERE id = ? AND notifications_enabled = 1',
[$userId]
);
if (!$enabled) return false;
$tokens = $this->db->fetchAll(
'SELECT id, token FROM user_fcm_tokens WHERE user_id = ?',
[$userId]
@@ -78,7 +84,11 @@ class FCMService
{
if (!$this->isConfigured()) return 0;
$tokens = $this->db->fetchAll('SELECT id, token FROM user_fcm_tokens');
$tokens = $this->db->fetchAll(
'SELECT f.id, f.token FROM user_fcm_tokens f
JOIN users u ON u.id = f.user_id
WHERE u.notifications_enabled = 1'
);
if (empty($tokens)) return 0;
$sent = 0;