mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-22 11:51:04 +02:00
fix: clean up ARI transferred call legs on participant hangup (#498)
This commit is contained in:
parent
ceb01a16a3
commit
b3e09be9b0
3 changed files with 209 additions and 3 deletions
|
|
@ -103,8 +103,16 @@ class ARIBridgeSwapStrategy(TransferStrategy):
|
|||
f"destination={destination_channel_id}, ext_media={ext_channel_id}"
|
||||
)
|
||||
|
||||
# 3. Set transfer state to prevent StasisEnd auto-teardown
|
||||
workflow_run.gathered_context["transfer_state"] = "in-progress"
|
||||
# 3. Set transfer state to prevent StasisEnd auto-teardown and
|
||||
# persist the transferred pair for post-handoff participant cleanup.
|
||||
workflow_run.gathered_context.update(
|
||||
{
|
||||
"transfer_state": "in-progress",
|
||||
"transfer_bridge_id": bridge_id,
|
||||
"transfer_caller_channel_id": channel_id,
|
||||
"transfer_destination_channel_id": destination_channel_id,
|
||||
}
|
||||
)
|
||||
await db_client.update_workflow_run(
|
||||
run_id=int(workflow_run_id),
|
||||
gathered_context=workflow_run.gathered_context,
|
||||
|
|
@ -124,6 +132,13 @@ class ARIBridgeSwapStrategy(TransferStrategy):
|
|||
logger.info(
|
||||
f"[ARI Transfer] Added destination {destination_channel_id} to bridge {bridge_id}"
|
||||
)
|
||||
# Let ari_manager route StasisEnd for the destination leg
|
||||
# back to this workflow after transfer context cleanup.
|
||||
await redis.setex(
|
||||
f"ari:channel:{destination_channel_id}",
|
||||
3600,
|
||||
workflow_run_id,
|
||||
)
|
||||
else:
|
||||
error_text = await response.text()
|
||||
logger.error(
|
||||
|
|
@ -169,6 +184,7 @@ class ARIBridgeSwapStrategy(TransferStrategy):
|
|||
)
|
||||
|
||||
# 5. Clean up transfer context after successful completion
|
||||
await redis.delete(f"ari:transfer_channel:{destination_channel_id}")
|
||||
|
||||
call_transfer_manager = await get_call_transfer_manager()
|
||||
await call_transfer_manager.remove_transfer_context(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue