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

24 lines
476 B
Ruby
Raw Normal View History

class Sessions::Event::ChatAgentState < Sessions::Event::ChatBase
2015-11-10 14:01:04 +00:00
def run
2015-12-09 13:09:37 +00:00
return super if super
2015-11-10 14:01:04 +00:00
# check if user has permissions
return if !agent_permission_check
2015-11-10 14:01:04 +00:00
2015-12-09 13:09:37 +00:00
Chat::Agent.state(@session['id'], @payload['data']['active'])
2015-11-10 14:01:04 +00:00
2015-11-15 10:01:48 +00:00
# broadcast new state to agents
broadcast_agent_state_update(@session['id'])
2015-11-10 14:01:04 +00:00
{
event: 'chat_agent_state',
data: {
state: 'ok',
2015-12-09 13:09:37 +00:00
active: @payload['data']['active'],
2015-11-10 14:01:04 +00:00
},
}
end
2015-12-09 13:09:37 +00:00
2015-11-10 14:01:04 +00:00
end