From 9ed1f5d96b558564bfcd5e3d1c6cc2b47790e33f Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Tue, 10 May 2022 19:20:55 +0530 Subject: [PATCH] Fix: Make version changeable from the environment vars (#4654) --- app/controllers/dashboard_controller.rb | 7 +++++-- app/javascript/dashboard/helper/scriptGenerator.js | 2 +- .../routes/dashboard/settings/inbox/channels/Facebook.vue | 2 +- .../dashboard/settings/inbox/facebook/Reauthorize.vue | 2 +- app/views/layouts/vueapp.html.erb | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 2bb8e9847..107aec56e 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -38,9 +38,12 @@ class DashboardController < ActionController::Base end def app_config - { APP_VERSION: Chatwoot.config[:version], + { + APP_VERSION: Chatwoot.config[:version], VAPID_PUBLIC_KEY: VapidService.public_key, ENABLE_ACCOUNT_SIGNUP: GlobalConfigService.load('ENABLE_ACCOUNT_SIGNUP', 'false'), - FB_APP_ID: GlobalConfigService.load('FB_APP_ID', '') } + FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''), + FACEBOOK_API_VERSION: 'v13.0' + } end end diff --git a/app/javascript/dashboard/helper/scriptGenerator.js b/app/javascript/dashboard/helper/scriptGenerator.js index 5a278d30a..bb6f2a72f 100644 --- a/app/javascript/dashboard/helper/scriptGenerator.js +++ b/app/javascript/dashboard/helper/scriptGenerator.js @@ -4,7 +4,7 @@ export const createMessengerScript = pageId => ` FB.init({ appId: "${window.chatwootConfig.fbAppId}", xfbml: true, - version: "v4.0" + version: "${window.chatwootConfig.fbApiVersion}" }); }; (function(d, s, id){ diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/Facebook.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/Facebook.vue index 820b4631b..31eff872e 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/Facebook.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/Facebook.vue @@ -163,7 +163,7 @@ export default { FB.init({ appId: window.chatwootConfig.fbAppId, xfbml: true, - version: 'v12.0', + version: window.chatwootConfig.fbApiVersion, status: true, }); window.fbSDKLoaded = true; diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/facebook/Reauthorize.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/facebook/Reauthorize.vue index 736642f29..d86ebaaff 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/facebook/Reauthorize.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/facebook/Reauthorize.vue @@ -40,7 +40,7 @@ export default { FB.init({ appId: window.chatwootConfig.fbAppId, xfbml: true, - version: 'v12.0', + version: window.chatwootConfig.fbApiVersion, status: true, }); window.fbSDKLoaded = true; diff --git a/app/views/layouts/vueapp.html.erb b/app/views/layouts/vueapp.html.erb index f7d7155d1..3f91ac042 100644 --- a/app/views/layouts/vueapp.html.erb +++ b/app/views/layouts/vueapp.html.erb @@ -34,6 +34,7 @@ window.chatwootConfig = { hostURL: '<%= ENV.fetch('FRONTEND_URL', '') %>', fbAppId: '<%= ENV.fetch('FB_APP_ID', nil) %>', + fbApiVersion: '<%= @global_config['FACEBOOK_API_VERSION'] %>', signupEnabled: '<%= @global_config['ENABLE_ACCOUNT_SIGNUP'] %>', <% if @global_config['VAPID_PUBLIC_KEY'] %> vapidPublicKey: new Uint8Array(<%= Base64.urlsafe_decode64(@global_config['VAPID_PUBLIC_KEY']).bytes %>),