2015-11-11 13:10:26 +00:00
|
|
|
class Sessions::Event::ChatBase
|
|
|
|
|
|
|
|
def initialize(data, session, client_id)
|
|
|
|
@data = data
|
|
|
|
@session = session
|
|
|
|
@client_id = client_id
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-11-11 20:44:54 +00:00
|
|
|
def pre
|
2015-11-11 13:10:26 +00:00
|
|
|
|
|
|
|
# check if feature is enabled
|
2015-11-12 13:19:41 +00:00
|
|
|
return if Setting.get('chat')
|
|
|
|
{
|
|
|
|
event: 'chat_error',
|
|
|
|
data: {
|
|
|
|
state: 'chat_disabled',
|
|
|
|
},
|
|
|
|
}
|
2015-11-11 13:10:26 +00:00
|
|
|
end
|
|
|
|
|
2015-11-11 20:44:54 +00:00
|
|
|
def post
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2015-11-12 22:56:56 +00:00
|
|
|
def broadcast_agent_state_update
|
|
|
|
|
|
|
|
# send broadcast to agents
|
|
|
|
Chat::Agent.where(active: true).each {|item|
|
|
|
|
data = {
|
|
|
|
event: 'chat_status_agent',
|
|
|
|
data: Chat.agent_state(item.updated_by_id),
|
|
|
|
}
|
|
|
|
Sessions.send_to(item.updated_by_id, data)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-11-11 13:10:26 +00:00
|
|
|
end
|