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

52 lines
951 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class Sessions::Event::ChatSessionTyping < Sessions::Event::ChatBase
2015-11-10 14:01:04 +00:00
=begin
a agent or customer is typing a chat session message
payload
{
event: 'chat_session_typing',
data: {},
}
return is sent as message back to peer
=end
def run
2015-12-09 13:09:37 +00:00
return super if super
return if !check_chat_session_exists
chat_session = current_chat_session
2015-11-10 14:01:04 +00:00
user_id = nil
if @session
user_id = @session['id']
2015-11-10 14:01:04 +00:00
end
message = {
event: 'chat_session_typing',
data: {
2015-11-10 14:01:04 +00:00
session_id: chat_session.session_id,
user_id: user_id,
2015-11-10 14:01:04 +00:00
},
}
# send to participents
chat_session.send_to_recipients(message, @client_id)
2015-11-10 14:01:04 +00:00
# send chat_session_init to agent
{
event: 'chat_session_typing',
data: {
session_id: chat_session.session_id,
2015-11-10 14:01:04 +00:00
self_written: true,
},
}
end
2015-12-09 13:09:37 +00:00
2015-11-10 14:01:04 +00:00
end