5bc8219db5
* Adds typing indicator for widget * typing indicator for agents in dashboard Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
27 lines
704 B
Ruby
27 lines
704 B
Ruby
class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController
|
|
include Events::Types
|
|
before_action :set_web_widget
|
|
before_action :set_contact
|
|
|
|
def toggle_typing
|
|
head :ok if conversation.nil?
|
|
|
|
if permitted_params[:typing_status] == 'on'
|
|
trigger_typing_event(CONVERSATION_TYPING_ON)
|
|
elsif permitted_params[:typing_status] == 'off'
|
|
trigger_typing_event(CONVERSATION_TYPING_OFF)
|
|
end
|
|
|
|
head :ok
|
|
end
|
|
|
|
private
|
|
|
|
def trigger_typing_event(event)
|
|
Rails.configuration.dispatcher.dispatch(event, Time.zone.now, conversation: conversation, user: @contact)
|
|
end
|
|
|
|
def permitted_params
|
|
params.permit(:id, :typing_status, :website_token)
|
|
end
|
|
end
|