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

14 lines
528 B
Ruby
Raw Normal View History

DiscourseEvent.on(:site_setting_saved) do |sitesetting|
2017-08-01 15:53:39 -04:00
isEnabledSetting = sitesetting.name == 'chat_integration_telegram_enabled'
isAccessToken = sitesetting.name == 'chat_integration_telegram_access_token'
2017-08-01 15:53:39 -04:00
if (isEnabledSetting || isAccessToken)
enabled = isEnabledSetting ? sitesetting.value == 't' : SiteSetting.chat_integration_telegram_enabled
if enabled
Scheduler::Defer.later("Setup Telegram Webhook") do
DiscourseChat::Provider::TelegramProvider.setup_webhook()
end
end
end
2017-08-01 15:53:39 -04:00
end