trabajo-afectivo/lib/sessions/event/chat_status_customer.rb

23 lines
581 B
Ruby
Raw Normal View History

class Sessions::Event::ChatStatusCustomer < Sessions::Event::ChatBase
def run
2015-12-09 13:09:37 +00:00
return super if super
return if !check_chat_exists
# check if it's a chat sessin reconnect
session_id = nil
2015-12-09 13:09:37 +00:00
if @payload['data']['session_id']
session_id = @payload['data']['session_id']
2015-11-12 15:58:47 +00:00
# update recipients of existing sessions
chat_session = Chat::Session.find_by(session_id: session_id)
chat_session.add_recipient(@client_id, true)
end
{
event: 'chat_status_customer',
data: current_chat.customer_state(session_id),
}
end
2015-12-09 13:09:37 +00:00
end