chat_session_typing.rb 951 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Sessions::Event::ChatSessionTyping < Sessions::Event::ChatBase
  3. =begin
  4. a agent or customer is typing a chat session message
  5. payload
  6. {
  7. event: 'chat_session_typing',
  8. data: {},
  9. }
  10. return is sent as message back to peer
  11. =end
  12. def run
  13. return super if super
  14. return if !check_chat_session_exists
  15. chat_session = current_chat_session
  16. user_id = nil
  17. if @session
  18. user_id = @session['id']
  19. end
  20. message = {
  21. event: 'chat_session_typing',
  22. data: {
  23. session_id: chat_session.session_id,
  24. user_id: user_id,
  25. },
  26. }
  27. # send to participents
  28. chat_session.send_to_recipients(message, @client_id)
  29. # send chat_session_init to agent
  30. {
  31. event: 'chat_session_typing',
  32. data: {
  33. session_id: chat_session.session_id,
  34. self_written: true,
  35. },
  36. }
  37. end
  38. end