From cbb2b147a3fa24b2045e85c3077f9cca4f127e05 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Mon, 4 Mar 2019 12:28:04 +0400 Subject: [PATCH 1/6] Handle supergroup upgrade error --- lib/redmine2chat/platforms/telegram.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/redmine2chat/platforms/telegram.rb b/lib/redmine2chat/platforms/telegram.rb index ea54536..9a13630 100644 --- a/lib/redmine2chat/platforms/telegram.rb +++ b/lib/redmine2chat/platforms/telegram.rb @@ -2,6 +2,12 @@ module Redmine2chat::Platforms class Telegram include Dry::Monads::Result::Mixin + class ChatUpgradedError + def self.===(e) + e.is_a?(::Telegram::Bot::Exceptions::ResponseError) && e.message.include?('group chat was upgraded to a supergroup chat') + end + end + def icon_path '/plugin_assets/redmine_2chat/images/telegram-icon.png' end @@ -42,7 +48,14 @@ def send_message(im_id, message, params = {}) bot_token: RedmineBots::Telegram.bot_token }.merge(params) - RedmineBots::Telegram::Bot::MessageSender.call(message_params) + begin + RedmineBots::Telegram::Bot::MessageSender.call(message_params) + rescue ChatUpgradedError => e + new_chat_id = e.send(:data).dig('parameters', 'migrate_to_chat_id') + issue_chat = IssueChat.find_by(im_id: im_id, platform_name: 'telegram') + new_chat_id && issue_chat&.update!(im_id: new_chat_id) || raise(e) + message_params.merge!(chat_id: new_chat_id) && retry + end end private From 46992282d979c05daa79422b486cef7fa1c1322e Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Mon, 4 Mar 2019 17:51:21 +0400 Subject: [PATCH 2/6] Fix toggle admin command --- lib/redmine2chat/telegram/bot/group_command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine2chat/telegram/bot/group_command.rb b/lib/redmine2chat/telegram/bot/group_command.rb index fe96a33..b677210 100644 --- a/lib/redmine2chat/telegram/bot/group_command.rb +++ b/lib/redmine2chat/telegram/bot/group_command.rb @@ -134,7 +134,7 @@ def can_manage_chat?(telegram_user) def edit_group_admin(telegram_user, is_admin = true) return unless issue.active_chat - RedmineBots::Telegram::Tdlib::ToggleChatAdmin.(issue.active_chat.im_id, telegram_user.id, is_admin) + RedmineBots::Telegram::Tdlib::ToggleChatAdmin.(issue.active_chat.im_id, telegram_user.id, is_admin).wait! end def left_chat_member From 4239126827c316924866d6cbc14cc18ec014ea64 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Thu, 16 May 2019 14:03:38 +0400 Subject: [PATCH 3/6] Fix remove_keyboard error --- lib/redmine2chat/telegram/commands/edit_issue_command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine2chat/telegram/commands/edit_issue_command.rb b/lib/redmine2chat/telegram/commands/edit_issue_command.rb index a8b4b6f..e93d664 100644 --- a/lib/redmine2chat/telegram/commands/edit_issue_command.rb +++ b/lib/redmine2chat/telegram/commands/edit_issue_command.rb @@ -248,7 +248,7 @@ def finish_with_error executing_command.destroy send_message( locale('incorrect_value'), - reply_markup: Telegram::Bot::Types::ReplyKeyboardRemove.new(hide_keyboard: true).to_json) + reply_markup: Telegram::Bot::Types::ReplyKeyboardRemove.new(remove_keyboard: true).to_json) end def executing_command From a19051473cfe96cf28676021eccb3a1ab898f445 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Wed, 22 May 2019 19:53:32 +0400 Subject: [PATCH 4/6] =?UTF-8?q?Don=E2=80=99t=20respond=20to=20locked=20mem?= =?UTF-8?q?bers=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/redmine2chat/telegram/commands/base_bot_command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine2chat/telegram/commands/base_bot_command.rb b/lib/redmine2chat/telegram/commands/base_bot_command.rb index 3402b79..3e7c0d2 100644 --- a/lib/redmine2chat/telegram/commands/base_bot_command.rb +++ b/lib/redmine2chat/telegram/commands/base_bot_command.rb @@ -36,7 +36,7 @@ def account @account ||= begin account = TelegramAccount.find_by!(telegram_id: command.from.id) - if account.user + if account.user && !account.user.locked? account else send_message(I18n.t('redmine_2chat.bot.account_not_connected')) From 3f8baff8287a47e0762c25bc9c3f798ab5c007a8 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Fri, 13 Sep 2019 18:39:18 +0400 Subject: [PATCH 5/6] Handle "Administrators editing is disabled" errors --- lib/redmine2chat/telegram/bot/group_command.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/redmine2chat/telegram/bot/group_command.rb b/lib/redmine2chat/telegram/bot/group_command.rb index b677210..f381852 100644 --- a/lib/redmine2chat/telegram/bot/group_command.rb +++ b/lib/redmine2chat/telegram/bot/group_command.rb @@ -5,6 +5,12 @@ module GroupCommand include ActionView::Helpers::TagHelper include ERB::Util + class AdminEditingDisabledError + def self.===(e) + e.is_a?(TD::Error) && e.message.include?('Administrators editing is disabled') + end + end + private def group_common_commands @@ -135,6 +141,8 @@ def can_manage_chat?(telegram_user) def edit_group_admin(telegram_user, is_admin = true) return unless issue.active_chat RedmineBots::Telegram::Tdlib::ToggleChatAdmin.(issue.active_chat.im_id, telegram_user.id, is_admin).wait! + rescue AdminEditingDisabledError + # skip end def left_chat_member From 73ac886c5fff4375b620fbde2887411023a8f57e Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Fri, 10 Jan 2020 19:28:07 +0400 Subject: [PATCH 6/6] Bump version --- .travis.yml | 12 +++++++++--- CHANGELOG.md | 8 ++++++++ README.md | 4 ++-- init.rb | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5c6625d..0d1d85e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: ruby rvm: - - 2.3.8 - - 2.6.0 + - 2.4.9 + - 2.6.5 + - 2.7.0 branches: only: @@ -13,7 +14,12 @@ addons: env: - REDMINE_VER=3.4-stable - - REDMINE_VER=4.0-stable + - REDMINE_VER=4.1-stable + +matrix: + exclude: + - env: REDMINE_VER=3.4-stable + rvm: 2.7.0 install: "echo skip bundle install" diff --git a/CHANGELOG.md b/CHANGELOG.md index 804b0ba..b422898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 0.3.2 + +* Handle supergroup upgrade error +* Fix toggle admin command +* Fix remove_keyboard error +* Don’t respond to locked members commands +* Handle "Administrators editing is disabled" errors + # 0.3.1 * Fix Rails 4 support diff --git a/README.md b/README.md index ffd6100..a0e6ba2 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Please help us make this plugin better telling us of any [issues](https://github ### Requirements -* **Ruby 2.3+** -* Configured [redmine_bots](https://github.com/centosadmin/redmine_bots) +* **Ruby 2.4+** +* Configured [redmine_bots](https://github.com/centosadmin/redmine_bots) (version 0.4.0 or higher) Standard plugin installation: diff --git a/init.rb b/init.rb index c869110..91bf1fa 100644 --- a/init.rb +++ b/init.rb @@ -49,11 +49,11 @@ name 'Redmine 2Chat' url 'https://github.com/centosadmin/redmine_2chat' description 'This is a plugin for Redmine which adds group chats to Redmine issues on different chat platforms such as Slack and Telegram.' - version '0.3.1' + version '0.3.2' author 'Southbridge' author_url 'https://github.com/centosadmin' - requires_redmine_plugin :redmine_bots, '0.2.0' + requires_redmine_plugin :redmine_bots, '0.4.0' settings(default: { 'daily_report' => '1',