diff --git a/app/models/address.rb b/app/models/address.rb index 78766a770..98a22ef11 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -26,7 +26,7 @@ class Address < ApplicationRecord after_save do if self.saved_changes['balance'].present? - TelegramBot.perform_async(self, self.balance - self.saved_changes['balance'][0].to_i) if self.tg_bots.active.exists? + TelegramBot.perform_async(self.id, self.balance - self.saved_changes['balance'][0].to_i) if self.tg_bots.active.exists? end end diff --git a/app/workers/telegram_bot.rb b/app/workers/telegram_bot.rb index 085e7dbec..c431918d4 100644 --- a/app/workers/telegram_bot.rb +++ b/app/workers/telegram_bot.rb @@ -2,7 +2,8 @@ class TelegramBot include Sidekiq::Worker require 'telegram/bot' sidekiq_options queue: "telegram" - def perform(address, change_balance) + def perform(address_id, change_balance) + address = Address.find_by(id: address_id) bot = Telegram::Bot::Client.new(Settings.tg_bot_token) address.tg_bots.active.each do |tg_bot| bot.api.send_message(chat_id: tg_bot.chat_id, text: "Address: #{tg_bot.address_hash}