chat_status_agent.rb 647 B

1234567891011121314151617181920212223
  1. class Sessions::Event::ChatStatusAgent < Sessions::Event::ChatBase
  2. def run
  3. return super if super
  4. # check if user has permissions
  5. return if !permission_check('chat.agent', 'chat')
  6. # renew timestamps
  7. state = Chat::Agent.state(@session['id'])
  8. Chat::Agent.state(@session['id'], state)
  9. # update recipients of existing sessions
  10. Chat::Session.where(state: 'running', user_id: @session['id']).order('created_at ASC').each do |chat_session|
  11. chat_session.add_recipient(@client_id, true)
  12. end
  13. {
  14. event: 'chat_status_agent',
  15. data: Chat.agent_state_with_sessions(@session['id']),
  16. }
  17. end
  18. end