Class: Telephony::CallObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/observers/telephony/call_observer.rb

Instance Method Summary collapse

Instance Method Details

#after_save(call) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/observers/telephony/call_observer.rb', line 3

def after_save(call)
  return unless call.agent_id

  Agent.find_with_lock(call.agent_id) do |agent|
    if call.terminated? && call.state_was != 'not_initiated' && call.state_was != 'terminated'
      agent.call_ended
    elsif call.connecting?
      agent.on_a_call
    end
  end
end