fix: al seleccionar id=0 en lista se activaba reset del multi-company
El id "0" de "Todas las fincas" coincidía con el keyword "0" en isResetKeyword, borrando la sesión multi-empresa y mostrando el pre-menú de empresa en vez de procesar la selección de finca. Solución: isResetKeyword solo aplica para mensajes de texto libre; las respuestas interactivas (list_reply/button_reply) nunca son comandos de reinicio. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c5955160bb
commit
5b0bd3b8b8
@@ -187,7 +187,7 @@ class WpWebhook
|
||||
}
|
||||
|
||||
// Pre-menú multi-empresa: retorna true si la empresa quedó resuelta, false si hay que esperar al usuario
|
||||
private static function handleMultiCompany(string $from, string $name, array $companies, string $rawText, string $phoneNumberId): bool
|
||||
private static function handleMultiCompany(string $from, string $name, array $companies, string $rawText, string $phoneNumberId, string $msgType = 'text'): bool
|
||||
{
|
||||
// 1. El usuario tocó un botón de selección de empresa
|
||||
if (str_starts_with($rawText, '__co_')) {
|
||||
@@ -233,7 +233,8 @@ class WpWebhook
|
||||
}
|
||||
|
||||
// 2. Keyword de reinicio → borrar sesión y mostrar pre-menú
|
||||
if (self::isResetKeyword($rawText)) {
|
||||
// Solo aplica para texto libre; las respuestas interactivas no son keywords
|
||||
if ($msgType === 'text' && self::isResetKeyword($rawText)) {
|
||||
try { db()->prepare("DELETE FROM multi_company_sessions WHERE wa_number = ?")->execute([$from]); } catch (\PDOException $e) {}
|
||||
self::sendCompanyPreMenu($from, $phoneNumberId, $name, $companies);
|
||||
return false;
|
||||
@@ -418,7 +419,7 @@ class WpWebhook
|
||||
'button' => $msg['button']['payload'] ?? $msg['button']['text'] ?? '',
|
||||
default => '',
|
||||
};
|
||||
if (!self::handleMultiCompany($from, $name, $matchedCompanies, $rawText, $phoneNumberId)) {
|
||||
if (!self::handleMultiCompany($from, $name, $matchedCompanies, $rawText, $phoneNumberId, $type)) {
|
||||
continue;
|
||||
}
|
||||
self::log('INFO', "Número {$from} → empresa (multi-sel): " . (self::$currentCompany['name'] ?? '?'));
|
||||
|
||||
Reference in New Issue
Block a user