Fix the build.

This commit is contained in:
Guo Xiang Tan 2019-06-06 10:26:24 +08:00
parent 3eb8e97f37
commit cef085d0b6
1 changed files with 24 additions and 14 deletions

View File

@ -1,21 +1,31 @@
# frozen_string_literal: true # frozen_string_literal: true
event = if Gem::Version.new(Discourse::VERSION::STRING) > Gem::Version.new("2.3.0.beta8")
if Gem::Version.new(Discourse::VERSION::STRING) > Gem::Version.new("2.3.0.beta8") DiscourseEvent.on(:site_setting_changed) do |setting_name, old_value, new_value|
:site_setting_changed isEnabledSetting = setting_name == 'chat_integration_telegram_enabled'
else isAccessToken = setting_name == 'chat_integration_telegram_access_token'
:site_setting_saved
if (isEnabledSetting || isAccessToken)
enabled = isEnabledSetting ? new_value == true : SiteSetting.chat_integration_telegram_enabled
if enabled
Scheduler::Defer.later("Setup Telegram Webhook") do
DiscourseChat::Provider::TelegramProvider.setup_webhook()
end
end
end
end end
else
DiscourseEvent.on(site_setting_saved) do |sitesetting|
isEnabledSetting = sitesetting.name == 'chat_integration_telegram_enabled'
isAccessToken = sitesetting.name == 'chat_integration_telegram_access_token'
DiscourseEvent.on(event) do |sitesetting| if (isEnabledSetting || isAccessToken)
isEnabledSetting = sitesetting.name == 'chat_integration_telegram_enabled' enabled = isEnabledSetting ? sitesetting.value == 't' : SiteSetting.chat_integration_telegram_enabled
isAccessToken = sitesetting.name == 'chat_integration_telegram_access_token' if enabled
Scheduler::Defer.later("Setup Telegram Webhook") do
if (isEnabledSetting || isAccessToken) DiscourseChat::Provider::TelegramProvider.setup_webhook()
enabled = isEnabledSetting ? sitesetting.value == 't' : SiteSetting.chat_integration_telegram_enabled end
if enabled
Scheduler::Defer.later("Setup Telegram Webhook") do
DiscourseChat::Provider::TelegramProvider.setup_webhook()
end end
end end
end end