Skip to content

Commit

Permalink
PISTON-1002: use collect_digits for DTMF during vm greeting/instructi…
Browse files Browse the repository at this point in the history
…ons (2600hz#6249)
  • Loading branch information
danielfinke authored May 1, 2020
1 parent 9a54ffb commit 2d45108
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
22 changes: 16 additions & 6 deletions applications/callflow/src/module/cf_voicemail.erl
Original file line number Diff line number Diff line change
Expand Up @@ -466,18 +466,28 @@ play_announcement(Box, Call) ->
end.

-spec start_composing_voicemail(mailbox(), kapps_call:call()) -> compose_return().
start_composing_voicemail(#mailbox{media_extension=Ext}=Box, Call) ->
start_composing_voicemail(#mailbox{interdigit_timeout=Interdigit
,media_extension=Ext
}=Box, Call) ->
lager:debug("playing mailbox greeting to caller"),
_ = play_greeting_intro(Box, Call),
_ = play_greeting(Box, Call),
_ = play_instructions(Box, Call),
_NoopId = kapps_call_command:noop(Call),
%% timeout after 5 min for safety, so this process cant hang around forever
case kapps_call_command:wait_for_application_or_dtmf(<<"noop">>, 5 * ?MILLISECONDS_IN_MINUTE) of
{'ok', _} ->
NoopId = kapps_call_command:noop(Call),
case kapps_call_command:collect_digits(?KEY_LENGTH
,0
,Interdigit
,NoopId
,[]
,'true'
,kapps_call_command:default_application_timeout()
,Call
)
of
{'ok', <<>>} ->
lager:info("played greeting and instructions to caller, recording new message"),
record_voicemail(tmp_file(Ext), Box, Call);
{'dtmf', Digit} ->
{'ok', Digit} ->
_ = kapps_call_command:b_flush(Call),
handle_compose_dtmf(Box, Call, Digit);
{'error', R} ->
Expand Down
14 changes: 14 additions & 0 deletions core/kazoo_call/src/kapps_call_command.erl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
-export([collect_digits/2, collect_digits/3
,collect_digits/4, collect_digits/5
,collect_digits/6, collect_digits/7
,collect_digits/8
]).
-export([send_command/2]).

Expand Down Expand Up @@ -2540,6 +2541,19 @@ collect_digits(MaxDigits, Timeout, Interdigit, NoopId, Terminators, FlushOnDigit
,flush_on_digit=FlushOnDigit
}).

-spec collect_digits(integer(), integer(), integer(), kz_term:api_binary(), list(), boolean(), integer(), kapps_call:call()) ->
collect_digits_return().
collect_digits(MaxDigits, Timeout, Interdigit, NoopId, Terminators, FlushOnDigit, AfterTimeout, Call) ->
do_collect_digits(#wcc_collect_digits{max_digits=kz_term:to_integer(MaxDigits)
,timeout=kz_term:to_integer(Timeout)
,interdigit=kz_term:to_integer(Interdigit)
,noop_id=NoopId
,terminators=Terminators
,call=Call
,flush_on_digit=FlushOnDigit
,after_timeout=kz_term:to_integer(AfterTimeout)
}).

-spec do_collect_digits(wcc_collect_digits()) -> collect_digits_return().
do_collect_digits(#wcc_collect_digits{max_digits=MaxDigits
,timeout=Timeout
Expand Down

0 comments on commit 2d45108

Please sign in to comment.