DEV: Fix new Rubocop offenses (#188)

* DEV: Fix new Rubocop offenses

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Loïc Guitaut 2024-03-04 16:01:07 +01:00 committed by GitHub
parent 5c8408e58b
commit 4f737df97e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 49 additions and 23 deletions

View File

@ -7,35 +7,60 @@ GIT
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
drb (2.2.0)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
minitest (5.22.2)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.0.3)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (0.24.0)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.59.0)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-ast (1.31.0)
parser (>= 3.3.0.4)
prism (>= 0.24.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-discourse (3.6.0)
rubocop-discourse (3.7.1)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
@ -44,8 +69,11 @@ GEM
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
PLATFORMS

View File

@ -1,16 +0,0 @@
# frozen_string_literal: true
DiscourseEvent.on(:site_setting_changed) do |setting_name, old_value, new_value|
isEnabledSetting = setting_name == :chat_integration_telegram_enabled
isAccessToken = setting_name == :chat_integration_telegram_access_token
if (isEnabledSetting || isAccessToken)
enabled = isEnabledSetting ? new_value == true : SiteSetting.chat_integration_telegram_enabled
if enabled && SiteSetting.chat_integration_telegram_access_token.present?
Scheduler::Defer.later("Setup Telegram Webhook") do
DiscourseChatIntegration::Provider::TelegramProvider.setup_webhook
end
end
end
end

View File

@ -115,4 +115,3 @@ module DiscourseChatIntegration
end
require_relative "telegram_command_controller.rb"
require_relative "telegram_initializer.rb"

View File

@ -20,6 +20,21 @@ require_relative "lib/discourse_chat_integration/provider/slack/slack_enabled_se
after_initialize do
require_relative "app/initializers/discourse_chat_integration"
on(:site_setting_changed) do |setting_name, old_value, new_value|
is_enabled_setting = setting_name == :chat_integration_telegram_enabled
is_access_token = setting_name == :chat_integration_telegram_access_token
if (is_enabled_setting || is_access_token)
enabled = is_enabled_setting ? new_value == true : SiteSetting.chat_integration_telegram_enabled
if enabled && SiteSetting.chat_integration_telegram_access_token.present?
Scheduler::Defer.later("Setup Telegram Webhook") do
DiscourseChatIntegration::Provider::TelegramProvider.setup_webhook
end
end
end
end
on(:post_created) do |post|
# This will run for every post, even PMs. Don't worry, they're filtered out later.
time = SiteSetting.chat_integration_delay_seconds.seconds