From 232e1a824005051ec76bd8daab34e33b3a92ef43 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Mon, 13 Jan 2020 17:59:51 +0400 Subject: [PATCH 1/7] Fix tdlib proxy --- lib/redmine_bots/telegram/tdlib/command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine_bots/telegram/tdlib/command.rb b/lib/redmine_bots/telegram/tdlib/command.rb index 30c1bda..fe34769 100644 --- a/lib/redmine_bots/telegram/tdlib/command.rb +++ b/lib/redmine_bots/telegram/tdlib/command.rb @@ -53,7 +53,7 @@ def connect if settings['tdlib_use_proxy'] && proxy = TelegramProxy.alive.socks5.first type = TD::Types::ProxyType::Socks5.new(username: proxy.user, password: proxy.password) - client.add_proxy(proxy.host, proxy.port, type, false).then do |td_proxy| + client.add_proxy(proxy.host, proxy.port, false, type).then do |td_proxy| client.enable_proxy(td_proxy.id) end.flat.then { client.ready } else From 20da6a4fe0cab3c357eb6a808de4c9e273461880 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Mon, 13 Jan 2020 18:20:39 +0400 Subject: [PATCH 2/7] Fix AddBot command --- lib/redmine_bots/telegram.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/redmine_bots/telegram.rb b/lib/redmine_bots/telegram.rb index 1a5f1bd..8ed554c 100644 --- a/lib/redmine_bots/telegram.rb +++ b/lib/redmine_bots/telegram.rb @@ -44,15 +44,7 @@ def self.init_bot bot_info = bot.api.get_me['result'] bot_name = bot_info['username'] - until bot_name.present? - sleep 60 - - bot = Telegram::Bot::Client.new(token) - bot_info = bot.api.get_me['result'] - bot_name = bot_info['username'] - - RedmineBots::Telegram::Tdlib::AddBot.(bot_name) if robot_id - end + RedmineBots::Telegram::Tdlib::AddBot.(bot_name) if robot_id plugin_settings = Setting.find_by(name: 'plugin_redmine_bots') From e244be87179612ed0d4e320a2b5f49c16163f997 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Mon, 13 Jan 2020 18:34:16 +0400 Subject: [PATCH 3/7] Fix robot_id detection --- lib/redmine_bots/telegram.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/redmine_bots/telegram.rb b/lib/redmine_bots/telegram.rb index 8ed554c..268473e 100644 --- a/lib/redmine_bots/telegram.rb +++ b/lib/redmine_bots/telegram.rb @@ -33,12 +33,10 @@ def self.init_bot self_info = {} if Setting.plugin_redmine_bots['telegram_phone_number'].present? - self_info = Tdlib::GetMe.call.rescue do - raise 'Please, set correct settings for plugin RedmineBots::Telegram' - end.value!.to_h + self_info = Tdlib::GetMe.call.rescue { {} }.value!.to_h end - robot_id = self_info['id'] + robot_id = self_info[:id] bot = Telegram::Bot::Client.new(token) bot_info = bot.api.get_me['result'] From 4683b9ff46f3f2ceea28f25b5a2621602914dd81 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Mon, 20 Jan 2020 22:14:05 +0400 Subject: [PATCH 4/7] Release ActiveRecord connections in concurrent-ruby threads --- app/controllers/redmine_telegram_setup_controller.rb | 2 +- app/workers/telegram_accounts_refresh_worker.rb | 4 +++- lib/redmine_bots/telegram/tdlib/close_chat.rb | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/redmine_telegram_setup_controller.rb b/app/controllers/redmine_telegram_setup_controller.rb index 0c15660..790ad58 100644 --- a/app/controllers/redmine_telegram_setup_controller.rb +++ b/app/controllers/redmine_telegram_setup_controller.rb @@ -19,7 +19,7 @@ def authorize promise = RedmineBots::Telegram::Tdlib::Authenticate.(params).then do RedmineBots::Telegram::Tdlib::FetchAllChats.call end.flat.then do - save_phone_settings(phone_number: params['phone_number']) + ActiveRecord::Base.connection_pool.with_connection { save_phone_settings(phone_number: params['phone_number']) } redirect_to plugin_settings_path('redmine_bots'), notice: t('redmine_bots.telegram.authorize.success') end diff --git a/app/workers/telegram_accounts_refresh_worker.rb b/app/workers/telegram_accounts_refresh_worker.rb index a511bf8..29bf429 100644 --- a/app/workers/telegram_accounts_refresh_worker.rb +++ b/app/workers/telegram_accounts_refresh_worker.rb @@ -6,7 +6,9 @@ class TelegramAccountsRefreshWorker def perform TelegramAccount.where.not(telegram_id: nil).find_each do |account| RedmineBots::Telegram::Tdlib::GetUser.(account.telegram_id).then do |user| - account.update_attributes(user.to_h.slice(*%w[username first_name last_name])) + ActiveRecord::Base.connection_pool.with_connection do + account.update_attributes(user.to_h.slice(*%w[username first_name last_name])) + end end.wait end end diff --git a/lib/redmine_bots/telegram/tdlib/close_chat.rb b/lib/redmine_bots/telegram/tdlib/close_chat.rb index a86de39..7e2ce3b 100644 --- a/lib/redmine_bots/telegram/tdlib/close_chat.rb +++ b/lib/redmine_bots/telegram/tdlib/close_chat.rb @@ -17,7 +17,11 @@ def call(chat_id) def fetch_robot_ids Promises.zip( - Promises.future { Setting.find_by(name: 'plugin_redmine_bots').value['telegram_bot_id'].to_i }, + Promises.future do + ActiveRecord::Base.connection_pool.with_connection do + Setting.find_by(name: 'plugin_redmine_bots').value['telegram_bot_id'].to_i + end + end, client.get_me.then(&:id) ) end From 76121da301b1aa9cbb9e135041ab71140f5326d0 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Tue, 21 Jan 2020 12:07:35 +0400 Subject: [PATCH 5/7] Remove ruby 2.7.0 from build matrix --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41e2003..43e9661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: ruby rvm: - 2.4.9 - 2.6.5 - - 2.7.0 branches: only: @@ -16,11 +15,6 @@ env: - REDMINE_VER=3.4-stable - REDMINE_VER=4.1-stable -matrix: - exclude: - - env: REDMINE_VER=3.4-stable - rvm: 2.7.0 - install: "echo skip bundle install" before_script: From fc958c309d6da9bb41fadf1ba2990a91f0144882 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Sun, 26 Jan 2020 16:51:36 +0400 Subject: [PATCH 6/7] Update sidekiq-rate-limiter --- Gemfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 964e61a..d7f13cf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,6 @@ gem 'pidfile', git: 'https://github.com/arturtr/pidfile.git' gem 'sidekiq-cron' -gem 'sidekiq-rate-limiter', git: 'https://github.com/centosadmin/sidekiq-rate-limiter', branch: 'master', - require: 'sidekiq-rate-limiter/server' +gem 'sidekiq-rate-limiter', '0.1.3', require: 'sidekiq-rate-limiter/server' gem 'telegram-bot-ruby', '>= 0.11', '< 1.0' gem 'slack-ruby-bot' From 0f8f7fb5d641af0445dc636266824a371605cb03 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Tue, 28 Jan 2020 13:28:30 +0400 Subject: [PATCH 7/7] Bump version [skip ci] --- CHANGELOG.md | 9 +++++++++ init.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b6869..1576c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 0.4.1 + +* Fix tdlib proxy +* Fix AddBot command +* Fix robot_id detection +* Release ActiveRecord connections in concurrent-ruby threads +* Remove ruby 2.7.0 from build matrix +* Update sidekiq-rate-limiter + # 0.4.0 * Handle Faraday::ClientError in MessageSender diff --git a/init.rb b/init.rb index 823f3f1..83ceffd 100644 --- a/init.rb +++ b/init.rb @@ -34,7 +34,7 @@ name 'Redmine Bots' url 'https://github.com/centosadmin/redmine_bots' description 'This is a platform for building Redmine bots' - version '0.4.0' + version '0.4.1' author 'Southbridge' author_url 'https://github.com/centosadmin'