up
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
$db = Database::getInstance();
|
||||
$col = $db->fetch("SHOW TABLES LIKE 'notifications'");
|
||||
if ($col) {
|
||||
echo "Table notifications already exists\n";
|
||||
exit(0);
|
||||
}
|
||||
try {
|
||||
$db->query("CREATE TABLE notifications (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NULL,
|
||||
type VARCHAR(64) NOT NULL,
|
||||
message TEXT,
|
||||
data JSON NULL,
|
||||
is_read TINYINT(1) DEFAULT 0,
|
||||
created_at DATETIME DEFAULT NOW(),
|
||||
INDEX idx_user_id (user_id),
|
||||
INDEX idx_is_read (is_read)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
|
||||
echo "Created notifications table\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Failed to create notifications table: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . '/../api/webhook.php';
|
||||
|
||||
// Simular payload de mensaje entrante para que webhook cree notificación
|
||||
$payload = [
|
||||
'object' => 'whatsapp_business_account',
|
||||
'entry' => [
|
||||
[
|
||||
'changes' => [
|
||||
[
|
||||
'field' => 'messages',
|
||||
'value' => [
|
||||
'messages' => [
|
||||
[
|
||||
'from' => '573019999900',
|
||||
'id' => 'NTFTEST1',
|
||||
'timestamp' => time(),
|
||||
'type' => 'text',
|
||||
'text' => ['body' => 'Notificacion test']
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$w = new WhatsAppWebhook();
|
||||
$w->processPayload($payload);
|
||||
|
||||
$db = Database::getInstance();
|
||||
$rows = $db->fetchAll('SELECT * FROM notifications ORDER BY id DESC LIMIT 5');
|
||||
foreach ($rows as $r) echo json_encode($r) . "\n";
|
||||
Reference in New Issue
Block a user