fix(voice): end Twilio conference before marking inbound reject terminal

This commit is contained in:
Tanmay Deep Sharma
2026-05-20 16:30:31 +05:30
parent 151d9d8117
commit f5691eadc9
@@ -27,8 +27,12 @@ class Api::V1::Accounts::ConferenceController < Api::V1::Accounts::BaseControlle
def destroy
call = resolve_call!
finalize_as_agent_reject!(call) if agent_rejecting_before_pickup?(call)
rejecting = agent_rejecting_before_pickup?(call)
# Tear down the provider conference before marking the call terminal: if
# end_conference raises, the call stays ringing (non-terminal) and remains
# repairable by later status webhooks instead of being stuck as failed.
Voice::Provider::Twilio::ConferenceService.new(call: call).end_conference
finalize_as_agent_reject!(call) if rejecting
render json: { status: 'success', id: call.conversation.display_id }
end