diff --git a/enterprise/app/controllers/twilio/voice_controller.rb b/enterprise/app/controllers/twilio/voice_controller.rb index 0bc4c67d8..7befb1a11 100644 --- a/enterprise/app/controllers/twilio/voice_controller.rb +++ b/enterprise/app/controllers/twilio/voice_controller.rb @@ -114,10 +114,12 @@ class Twilio::VoiceController < ApplicationController end def conference_twiml(call) + conference_sid = ensure_conference_sid!(call) + Twilio::TwiML::VoiceResponse.new.tap do |response| response.dial do |dial| dial.conference( - call.conference_sid, + conference_sid, start_conference_on_enter: agent_leg?(twilio_from), end_conference_on_exit: false, status_callback: conference_status_callback_url, @@ -129,6 +131,13 @@ class Twilio::VoiceController < ApplicationController end.to_s end + def ensure_conference_sid!(call) + return call.conference_sid if call.conference_sid.present? + + call.update!(conference_sid: Voice::Conference::Name.for(call)) + call.conference_sid + end + def participant_label_for(from_number) return from_number.delete_prefix('client:') if from_number.start_with?('client:') diff --git a/spec/factories/calls.rb b/spec/factories/calls.rb index d050449d9..40b8df24a 100644 --- a/spec/factories/calls.rb +++ b/spec/factories/calls.rb @@ -1,9 +1,9 @@ FactoryBot.define do factory :call do - association :account - association :inbox association :conversation - association :contact + account { conversation.account } + inbox { conversation.inbox } + contact { conversation.contact } provider { :twilio } direction { :incoming } status { 'ringing' }