diff --git a/lib/backend_sgx.rb b/lib/backend_sgx.rb index 7f386124027ec138f23bedd5a48d52be9ea41542..15b5591828ce45ac6c051df70f946cd5edc4625f 100644 --- a/lib/backend_sgx.rb +++ b/lib/backend_sgx.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class BackendSgx + VOICEMAIL_TRANSCRIPTION_DISABLED = 0 + def initialize(customer_id, jid=CONFIG[:sgx], creds=CONFIG[:creds]) @customer_id = customer_id @jid = jid @@ -37,6 +39,13 @@ class BackendSgx REDIS.get("catapult_ogm_url-#{from_jid}") end + def catapult_flag(flagbit) + REDIS.getbit( + "catapult_setting_flags-#{from_jid}", + flagbit + ).then { |x| x != 1 } + end + def fwd_timeout REDIS.get("catapult_fwd_timeout-#{from_jid}") end diff --git a/lib/customer.rb b/lib/customer.rb index b5b093c6ff008abff3a23c58a2b9221d28e28198..a2916229e12f968ac7401daecb39d20fd1429138 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -22,7 +22,7 @@ class Customer def_delegators :@plan, :active?, :activate_plan_starting_now, :bill_plan, :currency, :merchant_account, :plan_name, :auto_top_up_amount def_delegators :@sgx, :register!, :registered?, - :fwd_timeout, :set_fwd_timeout + :fwd_timeout, :set_fwd_timeout, :catapult_flag def_delegators :@usage, :usage_report, :message_usage, :incr_message_usage def initialize( diff --git a/views/voicemail.slim b/views/voicemail.slim index 7d5310118cd7c6ebd86702d4e9ee140cd10eefee..85118ed8bb2f260263d1babfda18ede2eb381a33 100644 --- a/views/voicemail.slim +++ b/views/voicemail.slim @@ -4,7 +4,7 @@ Response == render(*ogm.to_render) PlayAudio= "/beep.mp3" Record{ - transcribe="true" + transcribe=transcription_enabled.to_s recordingAvailableUrl="/inbound/calls/#{pseudo_call_id}/voicemail/audio" transcriptionAvailableUrl="/inbound/calls/#{pseudo_call_id}/voicemail/transcription" fileFormat="mp3"} / diff --git a/web.rb b/web.rb index f55b987b6b9b6b0f4514850ad4b9e5239a8af2d7..84911dff2770b71a5f3bb232051ebcc9a5a731a3 100644 --- a/web.rb +++ b/web.rb @@ -288,9 +288,18 @@ class Web < Roda r.post do customer_repo .find_by_tel(params["to"]) - .then { |customer| customer.ogm(params["from"]) } - .then do |ogm| - render :voicemail, locals: { ogm: ogm } + .then { |customer| + EMPromise.all([ + customer.ogm(params["from"]), + customer.catapult_flag( + BackendSgx::VOICEMAIL_TRANSCRIPTION_DISABLED + ) + ]) + }.then do |(ogm, transcription_disabled)| + render :voicemail, locals: { + ogm: ogm, + transcription_enabled: !transcription_disabled + } end end end