From a51af8ca688c06c1372cf4c20d243f3a6628ccc7 Mon Sep 17 00:00:00 2001 From: Muhsin Date: Wed, 1 Apr 2026 14:28:11 +0400 Subject: [PATCH] chore: fix review comments --- app/javascript/dashboard/helper/inbox.js | 5 ++++- .../dashboard/routes/dashboard/settings/inbox/Index.vue | 1 + .../dashboard/settings/inbox/components/ChannelName.vue | 4 ++-- .../enterprise/api/v1/accounts/inboxes_controller.rb | 2 ++ enterprise/app/models/enterprise/channel/twilio_sms.rb | 3 +-- enterprise/app/services/twilio/voice_teardown_service.rb | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/javascript/dashboard/helper/inbox.js b/app/javascript/dashboard/helper/inbox.js index 4bb2d5a00..a23e1fdc0 100644 --- a/app/javascript/dashboard/helper/inbox.js +++ b/app/javascript/dashboard/helper/inbox.js @@ -21,7 +21,10 @@ export const VOICE_CALL_PROVIDERS = { export const getVoiceCallProvider = inbox => { if (!inbox) return null; - if (inbox.channel_type === INBOX_TYPES.TWILIO && inbox.voice_enabled) { + const channelType = inbox.channel_type || inbox.channelType; + const voiceEnabled = inbox.voice_enabled || inbox.voiceEnabled; + + if (channelType === INBOX_TYPES.TWILIO && voiceEnabled) { return VOICE_CALL_PROVIDERS.TWILIO; } diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue index 838d3ac0b..884c198c4 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue @@ -145,6 +145,7 @@ const openDelete = inbox => { diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/ChannelName.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/ChannelName.vue index 5963d7c35..711217f32 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/ChannelName.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/ChannelName.vue @@ -12,7 +12,7 @@ const props = defineProps({ type: String, default: '', }, - voiceCallEnabled: { + voiceEnabled: { type: Boolean, default: false, }, @@ -48,7 +48,7 @@ const readableChannelName = computed(() => { return globalConfig.value.apiChannelName || t('INBOX_MGMT.CHANNELS.API'); } if (props.channelType === 'Channel::TwilioSms') { - if (props.voiceCallEnabled) { + if (props.voiceEnabled) { return t('INBOX_MGMT.CHANNELS.VOICE'); } return twilioChannelName(); diff --git a/enterprise/app/controllers/enterprise/api/v1/accounts/inboxes_controller.rb b/enterprise/app/controllers/enterprise/api/v1/accounts/inboxes_controller.rb index c6a52b8aa..0f4dc456f 100644 --- a/enterprise/app/controllers/enterprise/api/v1/accounts/inboxes_controller.rb +++ b/enterprise/app/controllers/enterprise/api/v1/accounts/inboxes_controller.rb @@ -38,6 +38,8 @@ module Enterprise::Api::V1::Accounts::InboxesController end def create_voice_channel + raise Pundit::NotAuthorizedError unless Current.account.feature_enabled?('channel_voice') + voice_params = params.require(:channel).permit( :phone_number, :provider, provider_config: [:account_sid, :auth_token, :api_key_sid, :api_key_secret] diff --git a/enterprise/app/models/enterprise/channel/twilio_sms.rb b/enterprise/app/models/enterprise/channel/twilio_sms.rb index 9639f80ca..6df7b33a3 100644 --- a/enterprise/app/models/enterprise/channel/twilio_sms.rb +++ b/enterprise/app/models/enterprise/channel/twilio_sms.rb @@ -75,8 +75,7 @@ module Enterprise::Channel::TwilioSms end def validate_voice_capability! - twilio_client = Twilio::REST::Client.new(account_sid, auth_token) - number = twilio_client.incoming_phone_numbers.list(phone_number: phone_number).first + number = client.incoming_phone_numbers.list(phone_number: phone_number).first raise 'Phone number not found in Twilio account' unless number raise 'This phone number does not support voice calls' unless number.capabilities['voice'] end diff --git a/enterprise/app/services/twilio/voice_teardown_service.rb b/enterprise/app/services/twilio/voice_teardown_service.rb index f343ce431..c6a897be9 100644 --- a/enterprise/app/services/twilio/voice_teardown_service.rb +++ b/enterprise/app/services/twilio/voice_teardown_service.rb @@ -16,7 +16,7 @@ class Twilio::VoiceTeardownService end def clear_voice_credentials - channel.update!(twiml_app_sid: nil) + channel.update(twiml_app_sid: nil) end def twilio_client