2015-11-11 13:10:26 +00:00
|
|
|
class Sessions::Event::ChatStatusCustomer < Sessions::Event::ChatBase
|
|
|
|
|
|
|
|
def run
|
2015-12-09 13:09:37 +00:00
|
|
|
return super if super
|
2015-11-25 09:33:39 +00:00
|
|
|
return if !check_chat_exists
|
2015-11-11 13:10:26 +00:00
|
|
|
|
2015-11-12 09:39:14 +00:00
|
|
|
# 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)
|
2016-03-25 07:45:21 +00:00
|
|
|
|
|
|
|
# sent url update to agent
|
|
|
|
if @payload['data']['url']
|
|
|
|
message = {
|
|
|
|
event: 'chat_session_notice',
|
|
|
|
data: {
|
|
|
|
session_id: chat_session.session_id,
|
|
|
|
message: @payload['data']['url'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
chat_session.send_to_recipients(message, @client_id)
|
|
|
|
end
|
2015-11-12 09:39:14 +00:00
|
|
|
end
|
2016-03-25 07:45:21 +00:00
|
|
|
|
2015-11-11 13:10:26 +00:00
|
|
|
{
|
|
|
|
event: 'chat_status_customer',
|
2015-11-25 09:33:39 +00:00
|
|
|
data: current_chat.customer_state(session_id),
|
2015-11-11 13:10:26 +00:00
|
|
|
}
|
|
|
|
end
|
2015-12-09 13:09:37 +00:00
|
|
|
|
2015-11-11 13:10:26 +00:00
|
|
|
end
|