diff --git a/app/models/integrations/app.rb b/app/models/integrations/app.rb index d8bf17448..eaf6ec3cf 100644 --- a/app/models/integrations/app.rb +++ b/app/models/integrations/app.rb @@ -3,6 +3,14 @@ class Integrations::App include Github::IntegrationHelper attr_accessor :params + INTEGRATION_CONFIGS = { + 'slack' => { config_key: 'SLACK_CLIENT_SECRET' }, + 'linear' => { config_key: 'LINEAR_CLIENT_ID' }, + 'shopify' => { feature_flag: 'shopify_integration', config_key: 'SHOPIFY_CLIENT_ID' }, + 'leadsquared' => { feature_flag: 'crm_integration' }, + 'github' => { feature_flag: 'github_integration', config_key: 'GITHUB_CLIENT_ID' } + }.freeze + def initialize(params) @params = params end @@ -57,20 +65,15 @@ class Integrations::App end def active?(account) - case params[:id] - when 'slack' - GlobalConfigService.load('SLACK_CLIENT_SECRET', nil).present? - when 'linear' - GlobalConfigService.load('LINEAR_CLIENT_ID', nil).present? - when 'shopify' - account.feature_enabled?('shopify_integration') && GlobalConfigService.load('SHOPIFY_CLIENT_ID', nil).present? - when 'leadsquared' - account.feature_enabled?('crm_integration') - when 'github' - account.feature_enabled?('github_integration') && GlobalConfigService.load('GITHUB_CLIENT_ID', nil).present? - else - true - end + config = INTEGRATION_CONFIGS[params[:id]] + return true unless config + + checks = [ + config[:feature_flag] ? account.feature_enabled?(config[:feature_flag]) : true, + config[:config_key] ? GlobalConfigService.load(config[:config_key], nil).present? : true + ] + + checks.all? end def build_linear_action diff --git a/config/integration/apps.yml b/config/integration/apps.yml index 928038bdb..c71503929 100644 --- a/config/integration/apps.yml +++ b/config/integration/apps.yml @@ -284,4 +284,5 @@ github: logo: github.png i18n_key: github hook_type: account + action: https://github.com/login/oauth/authorize allow_multiple_hooks: false