Feature: Implement multi-stage Conversation Flow Engine with TestFlow
This commit is contained in:
@@ -20,9 +20,10 @@ class ConversationState extends BaseModel
|
|||||||
{
|
{
|
||||||
self::ensureTableExists();
|
self::ensureTableExists();
|
||||||
$hash = Security::blindIndex($phone);
|
$hash = Security::blindIndex($phone);
|
||||||
|
$now = date('Y-m-d H:i:s');
|
||||||
$state = Database::selectOne(
|
$state = Database::selectOne(
|
||||||
"SELECT * FROM " . static::$table . " WHERE company_id = ? AND contact_phone_hash = ? AND expires_at > NOW() LIMIT 1",
|
"SELECT * FROM " . static::$table . " WHERE company_id = ? AND contact_phone_hash = ? AND expires_at > ? LIMIT 1",
|
||||||
[$companyId, $hash]
|
[$companyId, $hash, $now]
|
||||||
);
|
);
|
||||||
return self::decryptState($state);
|
return self::decryptState($state);
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,8 @@ class ConversationState extends BaseModel
|
|||||||
{
|
{
|
||||||
self::ensureTableExists();
|
self::ensureTableExists();
|
||||||
try {
|
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) {
|
} catch (\Exception $e) {
|
||||||
error_log("Failed to clean expired conversation states: " . $e->getMessage());
|
error_log("Failed to clean expired conversation states: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user