From 4956fbf180c9e3da0182dcca436e179e70c5e070 Mon Sep 17 00:00:00 2001 From: Sabiha Khan Date: Wed, 4 Mar 2026 18:50:46 +0530 Subject: [PATCH] chore: upgrade pipecat --- .../telephony/call_transfer_manager.py | 25 +++++++++++ .../providers/ari_call_strategies.py | 41 ++++--------------- pipecat | 2 +- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/api/services/telephony/call_transfer_manager.py b/api/services/telephony/call_transfer_manager.py index 6c1e0f6..a6f0f8c 100644 --- a/api/services/telephony/call_transfer_manager.py +++ b/api/services/telephony/call_transfer_manager.py @@ -185,6 +185,31 @@ class CallTransferManager: except Exception as e: logger.error(f"Error closing pubsub connection: {e}") + async def find_transfer_context_for_call(self, caller_channel_id: str): + """Find the active transfer context for this caller channel.""" + + redis = await self._get_redis() + + try: + # Search Redis for transfer contexts where original_call_sid matches this caller + transfer_keys = await redis.keys("transfer:context:*") + + for key in transfer_keys: + try: + context_data = await redis.get(key) + if context_data: + context = TransferContext.from_json(context_data) + if context.original_call_sid == caller_channel_id: + return context + except Exception: + continue + + return None + + except Exception as e: + logger.error(f"[ARI Transfer] Error finding transfer context: {e}") + return None + async def cleanup(self): """Clean up Redis connections.""" try: diff --git a/api/services/telephony/providers/ari_call_strategies.py b/api/services/telephony/providers/ari_call_strategies.py index 5986104..5225a29 100644 --- a/api/services/telephony/providers/ari_call_strategies.py +++ b/api/services/telephony/providers/ari_call_strategies.py @@ -42,11 +42,16 @@ class ARIBridgeSwapStrategy(TransferStrategy): from api.constants import REDIS_URL from api.db import db_client - + from api.services.telephony.call_transfer_manager import ( + get_call_transfer_manager, + ) auth = BasicAuth(app_name, app_password) + # Get call transfer manager instance + call_transfer_manager = await get_call_transfer_manager() + # 1. Find active transfer context for this caller channel - transfer_context = await self._find_transfer_context_for_call(channel_id) + transfer_context = await call_transfer_manager.find_transfer_context_for_call(channel_id) if not transfer_context: logger.error( f"[ARI Transfer] No active transfer context found for caller {channel_id}" @@ -162,9 +167,6 @@ class ARIBridgeSwapStrategy(TransferStrategy): ) # 5. Clean up transfer context after successful completion - from api.services.telephony.call_transfer_manager import ( - get_call_transfer_manager, - ) call_transfer_manager = await get_call_transfer_manager() await call_transfer_manager.remove_transfer_context( @@ -176,35 +178,6 @@ class ARIBridgeSwapStrategy(TransferStrategy): logger.exception(f"Failed to execute ARI transfer: {e}") return False - async def _find_transfer_context_for_call(self, caller_channel_id: str): - """Find the active transfer context for this caller channel.""" - try: - import redis.asyncio as aioredis - - from api.constants import REDIS_URL - from api.services.telephony.transfer_event_protocol import TransferContext - - # Search Redis for transfer contexts where original_call_sid matches this caller - redis = aioredis.from_url(REDIS_URL, decode_responses=True) - transfer_keys = await redis.keys("transfer:context:*") - - for key in transfer_keys: - try: - context_data = await redis.get(key) - if context_data: - context = TransferContext.from_json(context_data) - if context.original_call_sid == caller_channel_id: - return context - except Exception: - continue - - return None - - except Exception as e: - logger.error(f"[ARI Transfer] Error finding transfer context: {e}") - return None - - class ARIHangupStrategy(HangupStrategy): """Implements hangup for Asterisk ARI channels.""" diff --git a/pipecat b/pipecat index 3559c6a..791d241 160000 --- a/pipecat +++ b/pipecat @@ -1 +1 @@ -Subproject commit 3559c6a8eb9cc82b400d745ab62ed037a420b42f +Subproject commit 791d24196f07b36d64beddda4a9c79aa6ccdb245