Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PISTON-1002: use collect_digits for DTMF during vm greeting/instructions #6249

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
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
34 changes: 24 additions & 10 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 @@ -346,7 +347,7 @@ presence(State, PresenceId, CallId, 'undefined', 'undefined') ->
,{<<"To-Realm">>, Realm}
,{<<"State">>, State}
,{<<"Call-ID">>, CallId}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
]),
kapi_presence:publish_update(Command);
presence(State, PresenceId, CallId, TargetURI, 'undefined') ->
Expand All @@ -361,7 +362,7 @@ presence(State, PresenceId, CallId, TargetURI, 'undefined') ->
,{<<"To-Realm">>, Realm}
,{<<"State">>, State}
,{<<"Call-ID">>, CallId}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
]),
kapi_presence:publish_update(Command);
presence(State, PresenceId, CallId, TargetURI, Call) ->
Expand All @@ -378,7 +379,7 @@ presence(State, PresenceId, CallId, TargetURI, Call) ->
,{<<"To-Tag">>, kapps_call:to_tag(Call)}
,{<<"State">>, State}
,{<<"Call-ID">>, CallId}
| kz_api:default_headers(module_as_app(Call), ?APP_VERSION)
| kz_api:default_headers(module_as_app(Call), ?APP_VERSION)
]),
kapi_presence:publish_update(Command).

Expand Down Expand Up @@ -426,7 +427,7 @@ channel_status(Call) ->
b_channel_status('undefined') -> {'error', 'no_channel_id'};
b_channel_status(<<ChannelId/binary>>) ->
Command = [{<<"Call-ID">>, ChannelId}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
],
Resp = kz_amqp_worker:call_collect(Command
,fun kapi_call:publish_channel_status_req/1
Expand Down Expand Up @@ -506,7 +507,7 @@ audio_macro(Prompts, Call, GroupId) ->
,{<<"Msg-ID">>, NoopId}
,{<<"Call-ID">>, kapps_call:call_id(Call)}
])
| Queue
| Queue
],
Command = [{<<"Application-Name">>, <<"queue">>}
,{<<"Commands">>, Commands}
Expand Down Expand Up @@ -956,7 +957,7 @@ receive_fax(ResourceFlag, ReceiveFlag, Call) ->
receive_fax(ResourceFlag, ReceiveFlag, LocalFilename, Call) ->
Commands = props:filter_undefined([{<<"Application-Name">>, <<"receive_fax">>}
,{<<"Fax-Local-Filename">>, LocalFilename}
| get_inbound_t38_settings(ResourceFlag, ReceiveFlag)
| get_inbound_t38_settings(ResourceFlag, ReceiveFlag)
]),
send_command(Commands, Call).

Expand Down Expand Up @@ -1372,7 +1373,7 @@ soft_hold_command(CallId, UnholdKey, AMOH, BMOH, InsertAt) ->
,{<<"Call-ID">>, CallId}
,{<<"Insert-At">>, InsertAt}
,{<<"Unhold-Key">>, UnholdKey}
| build_moh_keys(AMOH, BMOH)
| build_moh_keys(AMOH, BMOH)
]).

-spec build_moh_keys(kz_term:api_binary(), kz_term:api_binary()) ->
Expand Down Expand Up @@ -1835,7 +1836,7 @@ record_call(Media, Action, TimeLimit, Terminators, Call) ->
,{<<"Time-Limit">>, Limit}
,{<<"Terminators">>, Terminators}
,{<<"Insert-At">>, <<"now">>}
| Media
| Media
]),
send_command(Command, Call).

Expand Down Expand Up @@ -2539,6 +2540,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 Expand Up @@ -3398,7 +3412,7 @@ store_file(Filename, URLFun, Tries, Timeout, Call) ->
API = fun() -> [{<<"Command">>, <<"send_http">>}
,{<<"Args">>, kz_json:from_list(store_file_args(Filename, URLFun))}
,{<<"FreeSWITCH-Node">>, kapps_call:switch_nodename(Call)}
| kz_api:default_headers(AppName, AppVersion)
| kz_api:default_headers(AppName, AppVersion)
]
end,
do_store_file(Tries, Timeout, API, Msg, Call).
Expand Down Expand Up @@ -3562,7 +3576,7 @@ sound_touch_command(Options, Call) ->
[{<<"Application-Name">>, <<"sound_touch">>}
,{<<"Insert-At">>, <<"now">>}
,{<<"Call-ID">>, kapps_call:call_id(Call)}
| Options
| Options
]).

-spec start_sound_touch(kz_term:proplist(), kapps_call:call()) -> 'ok'.
Expand Down