fix: remove redundant NotificationPoller to prevent duplicate notifications #82

Merged
rafaga21 merged 3 commits from feat/version-update-notification into master 2026-06-13 17:51:28 -04:00
2 changed files with 23 additions and 1 deletions
Showing only changes of commit 52947f7b21 - Show all commits

View File

@@ -299,6 +299,18 @@ class AdminController
return;
}
if ($userId) {
$userModel = new User();
$targetUser = $userModel->findById($userId);
if (!$targetUser || empty($targetUser['notifications_enabled'])) {
$this->view->json([
'success' => true,
'message' => 'Notification saved to database. User has notifications disabled.',
]);
return;
}
}
$notificationModel = new Notification();
$noteId = $notificationModel->create([
'user_id' => $userId,

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;