u
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../api/webhook.php';
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
|
||||
$w = new WhatsAppWebhook();
|
||||
// Build a fake 'value' structure with interactive list_reply
|
||||
$value = [
|
||||
'messages' => [
|
||||
[
|
||||
'from' => '573010000002',
|
||||
'id' => 'TEST_INT_1',
|
||||
'type' => 'interactive',
|
||||
'interactive' => [
|
||||
'type' => 'list_reply',
|
||||
'list_reply' => ['id' => 'option_2', 'title' => 'Consultar resultados']
|
||||
],
|
||||
'timestamp' => time()
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// Set current menu for user (simulate that menu was shown previously)
|
||||
$db = Database::getInstance();
|
||||
$db->update('users', ['current_menu_id' => 1, 'current_step' => 1], 'phone_number = :phone', ['phone' => '573010000002']);
|
||||
|
||||
// Use reflection to call private method processconversations
|
||||
$ref = new ReflectionClass($w);
|
||||
$m = $ref->getMethod('processconversations');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$m->invoke($w, $value);
|
||||
|
||||
// Check DB for last conversations for that phone
|
||||
$db = Database::getInstance();
|
||||
$user = $db->fetch('SELECT * FROM users WHERE phone_number = ?', ['573010000002']);
|
||||
if ($user) {
|
||||
$rows = $db->fetchAll('SELECT * FROM conversations WHERE user_id = ? ORDER BY created_at DESC LIMIT 5', [$user['id']]);
|
||||
print_r($user);
|
||||
print_r($rows);
|
||||
} else {
|
||||
echo "User not found\n";
|
||||
}
|
||||
Reference in New Issue
Block a user