Files
leadchat/app/jobs/webhooks/telegram_events_job.rb
Sojan Jose a4c9a2b2f2 chore: Support telegram edited_message events (#6785)
- Add support for telegram edited_message events: Update the user message back in the Chatwoot dashboard when updated by the contact on telegram
2023-03-29 18:48:16 +05:30

25 lines
706 B
Ruby

class Webhooks::TelegramEventsJob < ApplicationJob
queue_as :default
def perform(params = {})
return unless params[:bot_token]
channel = Channel::Telegram.find_by(bot_token: params[:bot_token])
return unless channel
process_event_params(channel, params)
end
private
def process_event_params(channel, params)
return unless params[:telegram]
if params.dig(:telegram, :edited_message).present?
Telegram::UpdateMessageService.new(inbox: channel.inbox, params: params['telegram'].with_indifferent_access).perform
else
Telegram::IncomingMessageService.new(inbox: channel.inbox, params: params['telegram'].with_indifferent_access).perform
end
end
end