Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
72 lines
1.7 KiB
Ruby
72 lines
1.7 KiB
Ruby
class Voice::Conference::Manager
|
|
pattr_initialize [:conversation!, :event!, :call_sid!, :participant_label]
|
|
|
|
def process
|
|
case event
|
|
when 'start'
|
|
ensure_conference_sid!
|
|
mark_ringing!
|
|
when 'join'
|
|
mark_in_progress! if agent_participant?
|
|
when 'leave'
|
|
handle_leave!
|
|
when 'end'
|
|
finalize_conference!
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def status_manager
|
|
@status_manager ||= Voice::CallStatus::Manager.new(
|
|
conversation: conversation,
|
|
call_sid: call_sid
|
|
)
|
|
end
|
|
|
|
def ensure_conference_sid!
|
|
attrs = conversation.additional_attributes || {}
|
|
return if attrs['conference_sid'].present?
|
|
|
|
attrs['conference_sid'] = Voice::Conference::Name.for(conversation)
|
|
conversation.update!(additional_attributes: attrs)
|
|
end
|
|
|
|
def mark_ringing!
|
|
return if current_status
|
|
|
|
status_manager.process_status_update('ringing')
|
|
end
|
|
|
|
def mark_in_progress!
|
|
status_manager.process_status_update('in-progress', timestamp: current_timestamp)
|
|
end
|
|
|
|
def handle_leave!
|
|
case current_status
|
|
when 'ringing'
|
|
status_manager.process_status_update('no-answer', timestamp: current_timestamp)
|
|
when 'in-progress'
|
|
status_manager.process_status_update('completed', timestamp: current_timestamp)
|
|
end
|
|
end
|
|
|
|
def finalize_conference!
|
|
return if %w[completed no-answer failed].include?(current_status)
|
|
|
|
status_manager.process_status_update('completed', timestamp: current_timestamp)
|
|
end
|
|
|
|
def current_status
|
|
conversation.additional_attributes&.dig('call_status')
|
|
end
|
|
|
|
def agent_participant?
|
|
participant_label.to_s.start_with?('agent')
|
|
end
|
|
|
|
def current_timestamp
|
|
Time.zone.now.to_i
|
|
end
|
|
end
|