2017-07-19 11:28:02 -04:00
|
|
|
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-07-19 11:28:02 -04:00
|
|
|
|
2017-08-01 15:53:39 -04:00
|
|
|
if (isEnabledSetting || isAccessToken)
|
2017-07-19 11:28:02 -04:00
|
|
|
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
|