Skip to content

Commit 995187b

Browse files
committed
Merge pull request #74 from southbridgeio/update-tg-methods-and-client-auth
Update tg methods and client auth for new tdlib version
2 parents aa0729e + eea1570 commit 995187b

File tree

18 files changed

+156
-62
lines changed

18 files changed

+156
-62
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 0.5.3
2+
3+
* Add step 3 to Telegram client authorization
4+
* Adapt tdlib commands for new version
5+
6+
# 0.5.2
7+
8+
* Merge old 'update' branch
9+
110
# 0.5.1
211

312
* Fix problem with telegram_id exceeding int.

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ gem 'sidekiq-rate-limiter', '0.1.3', require: 'sidekiq-rate-limiter/server'
55
gem 'telegram-bot-ruby', '>= 0.11', '< 1.0'
66
gem 'slack-ruby-bot'
77
gem 'celluloid-io'
8-
gem 'tdlib-ruby', '3.0.2'
9-
gem 'tdlib-schema', git: 'https://github.com/southbridgeio/tdlib-schema', branch: 'update'
8+
gem 'tdlib-ruby', git: 'https://github.com/southbridgeio/tdlib-ruby', tag: "v3.0.3"
9+
gem 'tdlib-schema', git: 'https://github.com/southbridgeio/tdlib-schema'
1010
gem 'jwt'
1111
gem 'filelock'
1212
gem 'patron'

app/controllers/redmine_telegram_setup_controller.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ def step_2
1414
end
1515
end
1616

17+
def step_3
18+
RedmineBots::Telegram::Tdlib.wrap do
19+
promise = RedmineBots::Telegram::Tdlib::Authenticate.(params).rescue do |error|
20+
redirect_to plugin_settings_path('redmine_bots'), alert: error.message
21+
end
22+
23+
RedmineBots::Telegram::Tdlib.permit_concurrent_loads { promise.wait! }
24+
end
25+
end
26+
1727
def authorize
1828
RedmineBots::Telegram::Tdlib.wrap do
1929
promise = RedmineBots::Telegram::Tdlib::Authenticate.(params).then do

app/views/redmine_telegram_setup/step_1.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h2><%= t 'redmine_bots.settings.telegram.authorize_client' %></h2>
22
<hr>
3-
<p><strong>1. <%= t 'redmine_bots.settings.telegram.auth_step_1' %></strong> — 2. <%= t 'redmine_bots.settings.telegram.auth_step_2' %></p>
3+
<p><strong>1. <%= t 'redmine_bots.settings.telegram.auth_step_1' %></strong> — 2. <%= t 'redmine_bots.settings.telegram.auth_step_2' %> — 3. <%= t 'redmine_bots.settings.telegram.auth_step_3' %></p>
44
<hr>
55

66
<%= form_tag telegram_setup_2_path, method: :post do %>

app/views/redmine_telegram_setup/step_2.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<h2><%= t 'redmine_bots.settings.telegram.authorize_client' %></h2>
22
<hr>
3-
<p><%= link_to telegram_setup_1_path do %>1. <%= t 'redmine_bots.settings.telegram.auth_step_1' %><% end %><strong>2. <%= t 'redmine_bots.settings.telegram.auth_step_2' %></strong></p>
3+
<p><%= link_to telegram_setup_1_path do %>1. <%= t 'redmine_bots.settings.telegram.auth_step_1' %><% end %><strong>2. <%= t 'redmine_bots.settings.telegram.auth_step_2' %></strong> — 3. <%= t 'redmine_bots.settings.telegram.auth_step_3' %></p>
44
<hr>
55

6-
<%= form_tag telegram_setup_authorize_path, method: :post do %>
6+
<%= form_tag telegram_setup_3_path, method: :post do %>
77
<p>
88
<label>
99
<%= t 'redmine_bots.settings.telegram.phone_code' %>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h2><%= t 'redmine_bots.settings.telegram.authorize_client' %></h2>
2+
<hr>
3+
<p><%= link_to telegram_setup_1_path do %>1. <%= t 'redmine_bots.settings.telegram.auth_step_1' %><% end %> — 2. <%= t 'redmine_bots.settings.telegram.auth_step_2' %><strong>3. <%= t 'redmine_bots.settings.telegram.auth_step_3' %></strong></p>
4+
<hr>
5+
6+
<%= form_tag telegram_setup_authorize_path, method: :post do %>
7+
<p>
8+
<label>
9+
<%= t 'redmine_bots.settings.telegram.password' %>
10+
</label>
11+
<%= text_field_tag 'password' %>
12+
<em class="info"><%= t 'redmine_bots.settings.telegram.password_hint' %></em>
13+
</p>
14+
15+
<input type="hidden" name="phone_number" value="<%= params[:phone_number] %>">
16+
<input type="hidden" name="phone_code_hash" value="<%= params[:phone_code_hash] %>">
17+
18+
<input type="submit" value="<%= t 'redmine_bots.settings.telegram.authorize_button' %>">
19+
<% end %>

config/locales/en.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ en:
1414
phone_number: "Phone Number"
1515
phone_number_hint: "Format: 78005553535"
1616
phone_code: "Telegram code"
17+
password: "Telegram password"
18+
password_hint: "If you do not have two-factor authentication enabled in the Telegram application, click the «Authorize» button."
1719
authorize_button_code: "Receive code"
1820
authorize_button: "Authorize"
1921
authorize_client: "Authorize Telegram client"
2022
authorize_hint: "To authorize Telegram, press the button below. Current authorization will be drop."
2123
plugin_link: "Back to the plugin settings"
2224
auth_step_1: "Receiving Telegram code"
23-
auth_step_2: "Authorization"
25+
auth_step_2: "Code authorization"
26+
auth_step_3: "Password authorization"
2427
reset: "Reset cache and authorization"
2528
bot_init: Initialize bot
2629
bot_deinit: Deinitialize bot

config/locales/ru.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ ru:
1515
phone_number: "Номер телефона"
1616
phone_number_hint: "В формате: 78005553535"
1717
phone_code: "Код из Telegram"
18+
password: "Пароль из Telegram"
19+
password_hint: "Если у вас не включена двухфакторная аутентификация в приложении Telegram, нажмите кнопку «Авторизовать»."
1820
authorize_button_code: "Получить код авторизации"
1921
authorize_client: "Авторизовать клиент Telegram"
2022
authorize_hint: "Чтобы авторизировать Telegram, нажмите кнопку ниже. Текущая авторизация сбросится."
2123
authorize_button: "Авторизовать"
2224
plugin_link: "К настройкам плагина"
2325
auth_step_1: "Получение кода авторизации"
24-
auth_step_2: "Авторизация"
26+
auth_step_2: "Авторизация кода"
27+
auth_step_3: "Авторизация пароля"
2528
reset: "Сбросить кеш и авторизацию"
2629
bot_init: Инициализировать бота
2730
bot_deinit: Деинициализировать бота

config/locales/zh-TW.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ zh-TW:
1414
phone_number: "電話號碼"
1515
phone_number_hint: "以台灣手機 0912-345-678 為例,需輸入:886912345678"
1616
phone_code: "Telegram 代碼"
17+
password: "Telegram 密碼"
18+
password_hint: "如果您沒有在 Telegram 應用程式中啟用雙重認證,請按一下「授權」按鈕。"
1719
authorize_button_code: "接收代碼"
1820
authorize_button: "授權"
1921
authorize_client: "授權給 Telegram 用戶端"
2022
authorize_hint: "請按下面的按鈕授權給 Telegram。目前的授權則會被清除。"
2123
plugin_link: "回到外掛設定"
2224
auth_step_1: "接收 Telegram 代碼"
23-
auth_step_2: "授權"
25+
auth_step_2: "代碼授權"
26+
auth_step_3: "密碼授權"
2427
reset: "重設快取及授權"
2528
bot_init: 初始化機器人
2629
bot_deinit: 停用機器人

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
scope :setup do
1010
get 'step_1' => 'redmine_telegram_setup#step_1', as: :telegram_setup_1
1111
post 'step_2' => 'redmine_telegram_setup#step_2', as: :telegram_setup_2
12+
post 'step_3' => 'redmine_telegram_setup#step_3', as: :telegram_setup_3
1213
post 'authorize' => 'redmine_telegram_setup#authorize', as: :telegram_setup_authorize
1314
delete 'reset' => 'redmine_telegram_setup#reset', as: :telegram_setup_reset
1415
end

0 commit comments

Comments
 (0)