diff --git a/app/javascript/sdk/IFrameHelper.js b/app/javascript/sdk/IFrameHelper.js index 9641a4226..2f3ad5cfd 100644 --- a/app/javascript/sdk/IFrameHelper.js +++ b/app/javascript/sdk/IFrameHelper.js @@ -121,7 +121,7 @@ export const IFrameHelper = { setupAudioListeners: () => { const { baseUrl = '' } = window.$chatwoot; - getAlertAudio(baseUrl).then(() => + getAlertAudio(baseUrl, 'widget').then(() => initOnEvents.forEach(event => { document.removeEventListener( event, diff --git a/app/javascript/shared/helpers/AudioNotificationHelper.js b/app/javascript/shared/helpers/AudioNotificationHelper.js index d4fbc9e2c..c3108f174 100644 --- a/app/javascript/shared/helpers/AudioNotificationHelper.js +++ b/app/javascript/shared/helpers/AudioNotificationHelper.js @@ -4,7 +4,7 @@ import { IFrameHelper } from 'widget/helpers/utils'; import { showBadgeOnFavicon } from './faviconHelper'; export const initOnEvents = ['click', 'touchstart', 'keypress', 'keydown']; -export const getAlertAudio = async (baseUrl = '') => { +export const getAlertAudio = async (baseUrl = '', type = 'dashboard') => { const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); const playsound = audioBuffer => { window.playAudioAlert = () => { @@ -17,7 +17,7 @@ export const getAlertAudio = async (baseUrl = '') => { }; try { - const resourceUrl = `${baseUrl}/dashboard/audios/ding.mp3`; + const resourceUrl = `${baseUrl}/audio/${type}/ding.mp3`; const audioRequest = new Request(resourceUrl); fetch(audioRequest) diff --git a/config/environments/development.rb b/config/environments/development.rb index 67ffa6a52..9791505d9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -82,7 +82,7 @@ Rails.application.configure do allow do origins '*' resource '/packs/*', headers: :any, methods: [:get, :options] - resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options] + resource '/audio/*', headers: :any, methods: [:get, :options] resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry'] end end diff --git a/config/environments/production.rb b/config/environments/production.rb index e538e2867..ac0567c62 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -121,7 +121,7 @@ Rails.application.configure do allow do origins '*' resource '/packs/*', headers: :any, methods: [:get, :options] - resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options] + resource '/audio/*', headers: :any, methods: [:get, :options] if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false)) resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry'] end diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 6e9b3dcf8..241b3f9a7 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -87,7 +87,7 @@ Rails.application.configure do allow do origins '*' resource '/packs/*', headers: :any, methods: [:get, :options] - resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options] + resource '/audio/*', headers: :any, methods: [:get, :options] end end end diff --git a/config/environments/test.rb b/config/environments/test.rb index 43b7108b8..3dfe52c68 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -58,7 +58,7 @@ Rails.application.configure do allow do origins '*' resource '/packs/*', headers: :any, methods: [:get, :options] - resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options] + resource '/audio/*', headers: :any, methods: [:get, :options] end end end diff --git a/public/dashboard/audios/ding.mp3 b/public/audio/dashboard/ding.mp3 similarity index 100% rename from public/dashboard/audios/ding.mp3 rename to public/audio/dashboard/ding.mp3 diff --git a/public/audio/widget/ding.mp3 b/public/audio/widget/ding.mp3 new file mode 100644 index 000000000..7c190424b Binary files /dev/null and b/public/audio/widget/ding.mp3 differ