fix: remove redundant NotificationPoller to prevent duplicate notifications #82
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user