Skip to content

Commit 3d08b7f

Browse files
Merge pull request #45 from southbridgeio/develop
Develop
2 parents 0b24544 + 0f8f7fb commit 3d08b7f

File tree

9 files changed

+24
-26
lines changed

9 files changed

+24
-26
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: ruby
22
rvm:
33
- 2.4.9
44
- 2.6.5
5-
- 2.7.0
65

76
branches:
87
only:
@@ -16,11 +15,6 @@ env:
1615
- REDMINE_VER=3.4-stable
1716
- REDMINE_VER=4.1-stable
1817

19-
matrix:
20-
exclude:
21-
- env: REDMINE_VER=3.4-stable
22-
rvm: 2.7.0
23-
2418
install: "echo skip bundle install"
2519

2620
before_script:

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 0.4.1
2+
3+
* Fix tdlib proxy
4+
* Fix AddBot command
5+
* Fix robot_id detection
6+
* Release ActiveRecord connections in concurrent-ruby threads
7+
* Remove ruby 2.7.0 from build matrix
8+
* Update sidekiq-rate-limiter
9+
110
# 0.4.0
211

312
* Handle Faraday::ClientError in MessageSender

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
gem 'pidfile', git: 'https://github.com/arturtr/pidfile.git'
22
gem 'sidekiq-cron'
3-
gem 'sidekiq-rate-limiter', git: 'https://github.com/centosadmin/sidekiq-rate-limiter', branch: 'master',
4-
require: 'sidekiq-rate-limiter/server'
3+
gem 'sidekiq-rate-limiter', '0.1.3', require: 'sidekiq-rate-limiter/server'
54

65
gem 'telegram-bot-ruby', '>= 0.11', '< 1.0'
76
gem 'slack-ruby-bot'

app/controllers/redmine_telegram_setup_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def authorize
1919
promise = RedmineBots::Telegram::Tdlib::Authenticate.(params).then do
2020
RedmineBots::Telegram::Tdlib::FetchAllChats.call
2121
end.flat.then do
22-
save_phone_settings(phone_number: params['phone_number'])
22+
ActiveRecord::Base.connection_pool.with_connection { save_phone_settings(phone_number: params['phone_number']) }
2323
redirect_to plugin_settings_path('redmine_bots'), notice: t('redmine_bots.telegram.authorize.success')
2424
end
2525

app/workers/telegram_accounts_refresh_worker.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ class TelegramAccountsRefreshWorker
66
def perform
77
TelegramAccount.where.not(telegram_id: nil).find_each do |account|
88
RedmineBots::Telegram::Tdlib::GetUser.(account.telegram_id).then do |user|
9-
account.update_attributes(user.to_h.slice(*%w[username first_name last_name]))
9+
ActiveRecord::Base.connection_pool.with_connection do
10+
account.update_attributes(user.to_h.slice(*%w[username first_name last_name]))
11+
end
1012
end.wait
1113
end
1214
end

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
name 'Redmine Bots'
3535
url 'https://github.com/southbridgeio/redmine_bots'
3636
description 'This is a platform for building Redmine bots'
37-
version '0.4.0'
37+
version '0.4.1'
3838
author 'Southbridge'
3939
author_url 'https://github.com/southbridgeio'
4040

lib/redmine_bots/telegram.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,16 @@ def self.init_bot
3333
self_info = {}
3434

3535
if Setting.plugin_redmine_bots['telegram_phone_number'].present?
36-
self_info = Tdlib::GetMe.call.rescue do
37-
raise 'Please, set correct settings for plugin RedmineBots::Telegram'
38-
end.value!.to_h
36+
self_info = Tdlib::GetMe.call.rescue { {} }.value!.to_h
3937
end
4038

41-
robot_id = self_info['id']
39+
robot_id = self_info[:id]
4240

4341
bot = Telegram::Bot::Client.new(token)
4442
bot_info = bot.api.get_me['result']
4543
bot_name = bot_info['username']
4644

47-
until bot_name.present?
48-
sleep 60
49-
50-
bot = Telegram::Bot::Client.new(token)
51-
bot_info = bot.api.get_me['result']
52-
bot_name = bot_info['username']
53-
54-
RedmineBots::Telegram::Tdlib::AddBot.(bot_name) if robot_id
55-
end
45+
RedmineBots::Telegram::Tdlib::AddBot.(bot_name) if robot_id
5646

5747
plugin_settings = Setting.find_by(name: 'plugin_redmine_bots')
5848

lib/redmine_bots/telegram/tdlib/close_chat.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def call(chat_id)
1717

1818
def fetch_robot_ids
1919
Promises.zip(
20-
Promises.future { Setting.find_by(name: 'plugin_redmine_bots').value['telegram_bot_id'].to_i },
20+
Promises.future do
21+
ActiveRecord::Base.connection_pool.with_connection do
22+
Setting.find_by(name: 'plugin_redmine_bots').value['telegram_bot_id'].to_i
23+
end
24+
end,
2125
client.get_me.then(&:id)
2226
)
2327
end

lib/redmine_bots/telegram/tdlib/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def connect
5353

5454
if settings['tdlib_use_proxy'] && proxy = TelegramProxy.alive.socks5.first
5555
type = TD::Types::ProxyType::Socks5.new(username: proxy.user, password: proxy.password)
56-
client.add_proxy(proxy.host, proxy.port, type, false).then do |td_proxy|
56+
client.add_proxy(proxy.host, proxy.port, false, type).then do |td_proxy|
5757
client.enable_proxy(td_proxy.id)
5858
end.flat.then { client.ready }
5959
else

0 commit comments

Comments
 (0)