Feature: Implement multi-stage Conversation Flow Engine with TestFlow

This commit is contained in:
Hamza-Ayed
2026-05-22 05:18:46 +03:00
parent 7ec4d9becb
commit 11fab57a6f

View File

@@ -20,9 +20,10 @@ class ConversationState extends BaseModel
{
self::ensureTableExists();
$hash = Security::blindIndex($phone);
$now = date('Y-m-d H:i:s');
$state = Database::selectOne(
"SELECT * FROM " . static::$table . " WHERE company_id = ? AND contact_phone_hash = ? AND expires_at > NOW() LIMIT 1",
[$companyId, $hash]
"SELECT * FROM " . static::$table . " WHERE company_id = ? AND contact_phone_hash = ? AND expires_at > ? LIMIT 1",
[$companyId, $hash, $now]
);
return self::decryptState($state);
}
@@ -68,7 +69,8 @@ class ConversationState extends BaseModel
{
self::ensureTableExists();
try {
Database::execute("DELETE FROM " . static::$table . " WHERE expires_at < NOW()");
$now = date('Y-m-d H:i:s');
Database::execute("DELETE FROM " . static::$table . " WHERE expires_at < ?", [$now]);
} catch (\Exception $e) {
error_log("Failed to clean expired conversation states: " . $e->getMessage());
}