diff --git a/app/controllers/super_admin/app_configs_controller.rb b/app/controllers/super_admin/app_configs_controller.rb
index 550b6c893..204bfc95b 100644
--- a/app/controllers/super_admin/app_configs_controller.rb
+++ b/app/controllers/super_admin/app_configs_controller.rb
@@ -32,22 +32,17 @@ class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
end
def allowed_configs
- @allowed_configs = case @config
- when 'facebook'
- %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT]
- when 'shopify'
- %w[SHOPIFY_CLIENT_ID SHOPIFY_CLIENT_SECRET]
- when 'microsoft'
- %w[AZURE_APP_ID AZURE_APP_SECRET]
- when 'email'
- ['MAILER_INBOUND_EMAIL_DOMAIN']
- when 'linear'
- %w[LINEAR_CLIENT_ID LINEAR_CLIENT_SECRET]
- when 'instagram'
- %w[INSTAGRAM_APP_ID INSTAGRAM_APP_SECRET INSTAGRAM_VERIFY_TOKEN INSTAGRAM_API_VERSION ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT]
- else
- %w[ENABLE_ACCOUNT_SIGNUP FIREBASE_PROJECT_ID FIREBASE_CREDENTIALS]
- end
+ mapping = {
+ 'facebook' => %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT],
+ 'shopify' => %w[SHOPIFY_CLIENT_ID SHOPIFY_CLIENT_SECRET],
+ 'microsoft' => %w[AZURE_APP_ID AZURE_APP_SECRET],
+ 'email' => ['MAILER_INBOUND_EMAIL_DOMAIN'],
+ 'linear' => %w[LINEAR_CLIENT_ID LINEAR_CLIENT_SECRET],
+ 'slack' => %w[SLACK_CLIENT_ID SLACK_CLIENT_SECRET],
+ 'instagram' => %w[INSTAGRAM_APP_ID INSTAGRAM_APP_SECRET INSTAGRAM_VERIFY_TOKEN INSTAGRAM_API_VERSION ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT]
+ }
+
+ @allowed_configs = mapping.fetch(@config, %w[ENABLE_ACCOUNT_SIGNUP FIREBASE_PROJECT_ID FIREBASE_CREDENTIALS])
end
end
diff --git a/app/models/integrations/app.rb b/app/models/integrations/app.rb
index d4e563f81..dfe889bfa 100644
--- a/app/models/integrations/app.rb
+++ b/app/models/integrations/app.rb
@@ -39,7 +39,8 @@ class Integrations::App
def action
case params[:id]
when 'slack'
- "#{params[:action]}&client_id=#{ENV.fetch('SLACK_CLIENT_ID', nil)}&redirect_uri=#{self.class.slack_integration_url}"
+ client_id = GlobalConfigService.load('SLACK_CLIENT_ID', nil)
+ "#{params[:action]}&client_id=#{client_id}&redirect_uri=#{self.class.slack_integration_url}"
when 'linear'
build_linear_action
else
@@ -50,7 +51,7 @@ class Integrations::App
def active?(account)
case params[:id]
when 'slack'
- ENV['SLACK_CLIENT_SECRET'].present?
+ GlobalConfigService.load('SLACK_CLIENT_SECRET', nil).present?
when 'linear'
GlobalConfigService.load('LINEAR_CLIENT_ID', nil).present?
when 'shopify'
diff --git a/app/views/super_admin/application/_icons.html.erb b/app/views/super_admin/application/_icons.html.erb
index fb10c1035..fabff914b 100644
--- a/app/views/super_admin/application/_icons.html.erb
+++ b/app/views/super_admin/application/_icons.html.erb
@@ -159,4 +159,7 @@
-
\ No newline at end of file
+
+
+
+
diff --git a/config/installation_config.yml b/config/installation_config.yml
index 2365c1865..66538d4ab 100644
--- a/config/installation_config.yml
+++ b/config/installation_config.yml
@@ -288,6 +288,20 @@
type: secret
## ------ End of Configs added for Linear ------ ##
+## ------ Configs added for Slack ------ ##
+- name: SLACK_CLIENT_ID
+ display_title: 'Slack Client ID'
+ value:
+ locked: false
+ description: 'Slack client ID'
+- name: SLACK_CLIENT_SECRET
+ display_title: 'Slack Client Secret'
+ value:
+ locked: false
+ description: 'Slack client secret'
+ type: secret
+## ------ End of Configs added for Slack ------ ##
+
# ------- Shopify Integration Config ------- #
- name: SHOPIFY_CLIENT_ID
display_title: 'Shopify Client ID'
diff --git a/enterprise/app/helpers/super_admin/features.yml b/enterprise/app/helpers/super_admin/features.yml
index 3767d6468..c20de2dfa 100644
--- a/enterprise/app/helpers/super_admin/features.yml
+++ b/enterprise/app/helpers/super_admin/features.yml
@@ -48,6 +48,12 @@ messenger:
enabled: true
icon: 'icon-messenger-line'
config_key: 'facebook'
+instagram:
+ name: 'Instagram'
+ description: 'Stay connected with your customers on Instagram'
+ enabled: true
+ icon: 'icon-instagram'
+ config_key: 'instagram'
whatsapp:
name: 'WhatsApp'
description: 'Manage your WhatsApp business interactions from Chatwoot.'
@@ -81,19 +87,19 @@ microsoft:
config_key: 'microsoft'
linear:
name: 'Linear'
- description: 'Configuration for setting up Linear'
+ description: 'Configuration for setting up Linear Integration'
enabled: true
icon: 'icon-linear'
config_key: 'linear'
-instagram:
- name: 'Instagram'
- description: 'Configuration for setting up Instagram'
+slack:
+ name: 'Slack'
+ description: 'Configuration for setting up Slack Integration'
enabled: true
- icon: 'icon-instagram'
- config_key: 'instagram'
+ icon: 'icon-slack'
+ config_key: 'slack'
shopify:
name: 'Shopify'
- description: 'Configuration for setting up Shopify'
+ description: 'Configuration for setting up Shopify Integration'
enabled: true
icon: 'icon-shopify'
config_key: 'shopify'
diff --git a/lib/global_config_service.rb b/lib/global_config_service.rb
index 8de1c50c9..0649c24af 100644
--- a/lib/global_config_service.rb
+++ b/lib/global_config_service.rb
@@ -1,6 +1,6 @@
class GlobalConfigService
def self.load(config_key, default_value)
- config = ENV.fetch(config_key) { GlobalConfig.get(config_key)[config_key] }
+ config = GlobalConfig.get(config_key)[config_key]
return config if config.present?
# To support migrating existing instance relying on env variables
diff --git a/lib/integrations/slack/hook_builder.rb b/lib/integrations/slack/hook_builder.rb
index 139ef3a5b..e9513df57 100644
--- a/lib/integrations/slack/hook_builder.rb
+++ b/lib/integrations/slack/hook_builder.rb
@@ -32,8 +32,8 @@ class Integrations::Slack::HookBuilder
def fetch_access_token
client = Slack::Web::Client.new
slack_access = client.oauth_v2_access(
- client_id: ENV.fetch('SLACK_CLIENT_ID', 'TEST_CLIENT_ID'),
- client_secret: ENV.fetch('SLACK_CLIENT_SECRET', 'TEST_CLIENT_SECRET'),
+ client_id: GlobalConfigService.load('SLACK_CLIENT_ID', 'TEST_CLIENT_ID'),
+ client_secret: GlobalConfigService.load('SLACK_CLIENT_SECRET', 'TEST_CLIENT_SECRET'),
code: params[:code],
redirect_uri: Integrations::App.slack_integration_url
)
diff --git a/spec/controllers/devise/omniauth_callbacks_controller_spec.rb b/spec/controllers/devise/omniauth_callbacks_controller_spec.rb
index 0a9c82f53..1a775f88f 100644
--- a/spec/controllers/devise/omniauth_callbacks_controller_spec.rb
+++ b/spec/controllers/devise/omniauth_callbacks_controller_spec.rb
@@ -23,6 +23,10 @@ RSpec.describe 'DeviseOverrides::OmniauthCallbacksController', type: :request do
end
describe '#omniauth_sucess' do
+ before do
+ GlobalConfig.clear_cache
+ end
+
it 'allows signup' do
with_modified_env ENABLE_ACCOUNT_SIGNUP: 'true', FRONTEND_URL: 'http://www.example.com' do
set_omniauth_config('test_not_preset@example.com')
diff --git a/spec/enterprise/services/enterprise/clearbit_lookup_service_spec.rb b/spec/enterprise/services/enterprise/clearbit_lookup_service_spec.rb
index 725aa6523..d746b9a83 100644
--- a/spec/enterprise/services/enterprise/clearbit_lookup_service_spec.rb
+++ b/spec/enterprise/services/enterprise/clearbit_lookup_service_spec.rb
@@ -49,6 +49,10 @@ RSpec.describe Enterprise::ClearbitLookupService do
end
context 'when Clearbit is not enabled' do
+ before do
+ GlobalConfig.clear_cache
+ end
+
it 'returns nil without making an API call' do
with_modified_env CLEARBIT_API_KEY: nil do
expect(Net::HTTP).not_to receive(:start)
diff --git a/spec/services/conversations/message_window_service_spec.rb b/spec/services/conversations/message_window_service_spec.rb
index 34c5ebbad..32542e87e 100644
--- a/spec/services/conversations/message_window_service_spec.rb
+++ b/spec/services/conversations/message_window_service_spec.rb
@@ -56,6 +56,7 @@ RSpec.describe Conversations::MessageWindowService do
describe 'on Facebook channels' do
before do
stub_request(:post, /graph.facebook.com/)
+ GlobalConfig.clear_cache
end
let!(:facebook_channel) { create(:channel_facebook_page) }