chat_session_notice.rb 788 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. class Sessions::Event::ChatSessionNotice < Sessions::Event::ChatBase
  2. =begin
  3. a customer action has triggered a notice to the agent (e. g. view url of customer has changed)
  4. payload
  5. {
  6. event: 'chat_session_notice',
  7. data: {
  8. message: 'url has changed to http://localhost',
  9. },
  10. }
  11. return is sent as message back to peer
  12. =end
  13. def run
  14. return super if super
  15. return if !check_chat_session_exists
  16. chat_session = current_chat_session
  17. return if !chat_session
  18. return if !@payload['data']['message']
  19. message = {
  20. event: 'chat_session_notice',
  21. data: {
  22. session_id: chat_session.session_id,
  23. message: @payload['data']['message'],
  24. },
  25. }
  26. chat_session.send_to_recipients(message, @client_id)
  27. nil
  28. end
  29. end