discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_initializer.rb

17 lines
640 B
Ruby
Raw Normal View History

# 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
2019-06-05 22:26:24 -04:00
if (isEnabledSetting || isAccessToken)
enabled = isEnabledSetting ? new_value == true : SiteSetting.chat_integration_telegram_enabled
2019-06-05 21:51:40 -04:00
if enabled && SiteSetting.chat_integration_telegram_access_token.present?
Scheduler::Defer.later("Setup Telegram Webhook") do
DiscourseChatIntegration::Provider::TelegramProvider.setup_webhook
end
end
end
2017-08-01 15:53:39 -04:00
end