chat_session_notice.rb 865 B

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