Files
whatsapp/scripts/test_add_notification.php
T
2026-01-22 00:19:20 -05:00

24 lines
663 B
PHP

<?php
require_once __DIR__ . '/../config/config_enhanced.php';
$db = Database::getInstance();
// Get an existing user_id (user of conversations)
$user = $db->fetch('SELECT id, phone_number FROM users LIMIT 1');
$userId = $user['id'] ?? null;
$data = [
'user_id' => $userId,
'type' => 'message',
'message' => 'Prueba: nuevo mensaje recibido',
'data' => json_encode(['phone' => $user['phone_number'] ?? '']),
'is_read' => 0,
'created_at' => date('Y-m-d H:i:s')
];
$id = $db->insert('notifications', $data);
if ($id) {
echo "Inserted notification id=$id for user_id={$userId}\n";
} else {
echo "Failed to insert notification\n";
}