Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Application < Rails::Application
config.asset_sources = AssetSources.new(
manifest_path: Rails.public_path.join('packs', 'manifest.json'),
cache_manifest: Rails.env.production? || Rails.env.test?,
i18n_locales: Idp::Constants::AVAILABLE_LOCALES,
i18n_locales: IdentityConfig.store.available_locales,
)

console do
Expand Down Expand Up @@ -113,7 +113,7 @@ class Application < Rails::Application
config.time_zone = 'UTC'

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{yml}')]
config.i18n.available_locales = Idp::Constants::AVAILABLE_LOCALES
config.i18n.available_locales = IdentityConfig.store.available_locales
config.i18n.default_locale = :en
config.action_controller.per_form_csrf_tokens = true

Expand Down
1 change: 1 addition & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aamva_verification_url: https://example.org:12345/verification/url
all_redirect_uris_cache_duration_minutes: 2
allowed_ialmax_providers: '[]'
allowed_verified_within_providers: '[]'
available_locales: 'en,es,fr'
account_reset_token_valid_for_days: 1
account_reset_fraud_user_wait_period_days:
account_reset_wait_period_days: 1
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/rack_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Timeout
'/verify/document_capture',
'/verify/link_sent',
].flat_map do |path|
[path] + Idp::Constants::AVAILABLE_LOCALES.map { |locale| "/#{locale}#{path}" }
[path] + IdentityConfig.store.available_locales.map { |locale| "/#{locale}#{path}" }
end + ['/api/verify/images']).freeze

def call_with_excludes(env)
Expand Down
1 change: 1 addition & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def self.build_store(config_map)
config.add(:async_wait_timeout_seconds, type: :integer)
config.add(:attribute_encryption_key, type: :string)
config.add(:attribute_encryption_key_queue, type: :json)
config.add(:available_locales, type: :comma_separated_string_list)
config.add(:aws_http_retry_limit, type: :integer)
config.add(:aws_http_retry_max_delay, type: :integer)
config.add(:aws_http_timeout, type: :integer)
Expand Down
1 change: 0 additions & 1 deletion lib/idp/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module Idp
module Constants
AVAILABLE_LOCALES = %w[en es fr].freeze
UUID_REGEX = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/

KMS_LOG_FILENAME = 'kms.log'
Expand Down
17 changes: 7 additions & 10 deletions lib/telephony/pinpoint/voice_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
module Telephony
module Pinpoint
class VoiceSender
DEFAULT_VOICE_ID = ['en-US', 'Joey'].freeze
LANGUAGE_CODE_TO_VOICE_ID = {
en: DEFAULT_VOICE_ID,
fr: ['fr-FR', 'Mathieu'],
es: ['es-US', 'Miguel'],
}.freeze
# One connection pool per config (aka per-region)
# rubocop:disable Style/MutableConstant
CLIENT_POOL = Hash.new do |h, voice_config|
Expand Down Expand Up @@ -98,16 +104,7 @@ def handle_pinpoint_error(err)
end

def language_code_and_voice_id
case I18n.locale.to_sym
when :en
['en-US', 'Joey']
when :fr
['fr-FR', 'Mathieu']
when :es
['es-US', 'Miguel']
else
['en-US', 'Joey']
end
LANGUAGE_CODE_TO_VOICE_ID.fetch(I18n.locale.to_sym, DEFAULT_VOICE_ID)
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/telephony/pinpoint/voice_sender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ def mock_build_clients(client: pinpoint_client, backup_client: backup_pinpoint_c
)
end

describe 'LANGUAGE_CODE_TO_VOICE_ID' do
it 'contains a key for every available locale' do
expect(
Telephony::Pinpoint::VoiceSender::LANGUAGE_CODE_TO_VOICE_ID.keys.sort,
).to eq I18n.available_locales.sort
end
end
describe '#deliver' do
let(:pinpoint_response) do
double(message_id: 'fake-message-id')
Expand Down