mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-25 12:01:04 +02:00
chore: incorporate review comments
This commit is contained in:
parent
656977d7cd
commit
acce761917
2 changed files with 19 additions and 0 deletions
|
|
@ -261,6 +261,7 @@ class ARIHangupStrategy(HangupStrategy):
|
|||
(Redis ``ari:channel:{id}`` -> run_id -> ``initial_context``). Best-effort:
|
||||
never blocks dograh's own hangup if the upstream call fails.
|
||||
"""
|
||||
redis = None
|
||||
try:
|
||||
import redis.asyncio as aioredis
|
||||
|
||||
|
|
@ -319,3 +320,9 @@ class ARIHangupStrategy(HangupStrategy):
|
|||
)
|
||||
except Exception as e:
|
||||
logger.error(f"[ARI Hangup] external PBX terminate check failed: {e}")
|
||||
finally:
|
||||
if redis is not None:
|
||||
try:
|
||||
await redis.aclose()
|
||||
except Exception as e:
|
||||
logger.warning(f"[ARI Hangup] failed to close Redis client: {e}")
|
||||
|
|
|
|||
|
|
@ -204,3 +204,15 @@ async def test_hangup_strategy_updates_lead_before_customer_leg(monkeypatch):
|
|||
run.initial_context["external_pbx_call"], {"address3": "yes"}
|
||||
)
|
||||
adapter.hangup.assert_awaited_once_with(run.initial_context["external_pbx_call"])
|
||||
redis.aclose.assert_awaited_once_with()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hangup_strategy_closes_redis_when_channel_has_no_run(monkeypatch):
|
||||
redis = AsyncMock()
|
||||
redis.get.return_value = None
|
||||
monkeypatch.setattr(aioredis, "from_url", lambda *args, **kwargs: redis)
|
||||
|
||||
await ARIHangupStrategy()._terminate_external_pbx_if_any("missing-channel")
|
||||
|
||||
redis.aclose.assert_awaited_once_with()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue