From 92e22d65da4ed8fac5b8c4a28809479feffd651c Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 7 Sep 2017 22:45:54 +0100 Subject: [PATCH] Fix onceoff job to only run when slack is installed --- .../onceoff/migrate_from_slack_official.rb | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/jobs/onceoff/migrate_from_slack_official.rb b/app/jobs/onceoff/migrate_from_slack_official.rb index de8fe42..218740c 100644 --- a/app/jobs/onceoff/migrate_from_slack_official.rb +++ b/app/jobs/onceoff/migrate_from_slack_official.rb @@ -4,17 +4,19 @@ module Jobs # Check if slack plugin is installed by testing if the sitesetting exists slack_installed = defined? DiscourseSlack - already_setup_rules = DiscourseChat::Channel.with_provider('slack').exists? + if slack_installed + already_setup_rules = DiscourseChat::Channel.with_provider('slack').exists? - already_setup_sitesettings = - SiteSetting.chat_integration_slack_enabled || - !SiteSetting.chat_integration_slack_access_token.blank? || - !SiteSetting.chat_integration_slack_incoming_webhook_token.blank? || - !SiteSetting.chat_integration_slack_outbound_webhook_url.blank? + already_setup_sitesettings = + SiteSetting.chat_integration_slack_enabled || + !SiteSetting.chat_integration_slack_access_token.blank? || + !SiteSetting.chat_integration_slack_incoming_webhook_token.blank? || + !SiteSetting.chat_integration_slack_outbound_webhook_url.blank? - if !already_setup_rules && !already_setup_sitesettings - migrate_settings() - migrate_data() + if !already_setup_rules && !already_setup_sitesettings + migrate_settings() + migrate_data() + end end end