From 1730e610d6758943f633627ba44bdb23a8c6e5e1 Mon Sep 17 00:00:00 2001 From: tianlitao <2423806988@qq.com> Date: Fri, 22 Dec 2023 23:28:31 +0800 Subject: [PATCH] modify bug --- app/models/address.rb | 2 +- app/workers/telegram_bot.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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}