From 94766da41ffc065551de1aa7a268edf4f379f6da Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 20 Sep 2021 09:25:06 -0500 Subject: [PATCH] Support transcription disablement option --- lib/backend_sgx.rb | 9 +++++++++ lib/customer.rb | 2 +- views/voicemail.slim | 2 +- web.rb | 15 ++++++++++++--- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/backend_sgx.rb b/lib/backend_sgx.rb index 7f38612..15b5591 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 b5b093c..a291622 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 7d53101..85118ed 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 f55b987..84911df 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 -- 2.34.7