- Add support for telegram edited_message events: Update the user message back in the Chatwoot dashboard when updated by the contact on telegram
25 lines
706 B
Ruby
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
|