fix: mantenimiento PDF vacio — conservar grupo_mant y detectar placeholders
preservingReset borraba grupo_mant despues de cada informe, dejando
{grupo_id} sin resolver en la siguiente llamada del mismo submenu.
La API recibia grupo=0 y devolvia cero filas sin error visible.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
09db466fa6
commit
671fccd6b2
+11
-1
@@ -1152,7 +1152,9 @@ class NormalBot
|
||||
private static function preservingReset(int $ctxId, array $meta): void
|
||||
{
|
||||
$keep = [];
|
||||
foreach (['finca'] as $group) {
|
||||
// grupo_mant se conserva: el submenú de mantenimiento ofrece varios informes
|
||||
// sobre el mismo grupo, y perderlo dejaba {grupo_id} sin resolver.
|
||||
foreach (['finca', 'grupo_mant'] as $group) {
|
||||
if (isset($meta[$group])) $keep[$group] = $meta[$group];
|
||||
}
|
||||
ConversationContext::reset($ctxId);
|
||||
@@ -1287,6 +1289,14 @@ class NormalBot
|
||||
self::substituteUrlVars($ep['url'], array_merge($meta, ['__ep_vars_combined' => $meta['__ep_vars_combined'] ?? []])),
|
||||
$company
|
||||
);
|
||||
// Placeholder sin resolver → la API recibiría basura y devolvería un informe
|
||||
// vacío sin explicación. Mejor pedir el dato que falta.
|
||||
if (preg_match('/\{(\w+)\}/', $url, $ph)) {
|
||||
self::log("API report: falta '{$ph[1]}' para [{$endpointKey}] — url: {$url}");
|
||||
self::preservingReset($ctxId, ConversationContext::getMetadata($ctxId));
|
||||
return self::sendText('Falta seleccionar un dato para generar este informe.' . $nav, $context['from'], $company);
|
||||
}
|
||||
|
||||
$method = strtoupper($ep['method'] ?? 'GET');
|
||||
$apiKey = $company['api_key'] ?? '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user