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
This commit is contained in:
Sojan Jose
2023-03-29 18:48:16 +05:30
committed by GitHub
parent d1b65b6c9e
commit a4c9a2b2f2
5 changed files with 112 additions and 3 deletions

View File

@@ -7,6 +7,18 @@ class Webhooks::TelegramEventsJob < ApplicationJob
channel = Channel::Telegram.find_by(bot_token: params[:bot_token])
return unless channel
Telegram::IncomingMessageService.new(inbox: channel.inbox, params: params['telegram'].with_indifferent_access).perform
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