From 315c23e77073578afece193bc631c1e198db0657 Mon Sep 17 00:00:00 2001 From: Roger Neate Date: Fri, 16 Oct 2020 18:42:58 +0000 Subject: [PATCH 1/2] PISTON-1123: Fixes voicemail forward confirmation. The `cf_voicemail:forward_message/6` function has been refactored to consistently execute the forwarding operation as an asynchronous task and to play the confirmation of the operation synchronously. The previous flow of control was inconsistent, depending on configuration. In some circumstances, the forwarding operation was performed asynchronously, but this resulted in no audible confirmation. In other circumstances, forwarding was performed synchronously. --- .../callflow/src/module/cf_voicemail.erl | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/applications/callflow/src/module/cf_voicemail.erl b/applications/callflow/src/module/cf_voicemail.erl index dae81603349..3a30b83e236 100644 --- a/applications/callflow/src/module/cf_voicemail.erl +++ b/applications/callflow/src/module/cf_voicemail.erl @@ -1213,24 +1213,39 @@ maybe_forward(AttachmentName, Message, SourceBoxId, #mailbox{media_extension=Ext {'ok', 'record'} -> record_forward(tmp_file(Ext), Message, SourceBoxId, DestinationBox, Call); {'ok', _Selection} -> - cf_util:start_task(fun forward_message/6 - ,[AttachmentName, Length, Message, SourceBoxId, DestinationBox] - , Call - ) + forward_message(AttachmentName, Length, Message, SourceBoxId, DestinationBox, Call) end; maybe_forward(AttachmentName, Message, SourceBoxId, DestinationBox, Call, Msg, {'error', _E}) -> Length = kz_json:get_integer_value(<<"Length">>, Msg, 0), forward_message(AttachmentName, Length, Message, SourceBoxId, DestinationBox, Call). +%%------------------------------------------------------------------------------ +%% @doc Starts a task to asynchronously forward a message to another vmbox and +%% plays a confirmation of the operation. +%% @end +%%------------------------------------------------------------------------------ -spec forward_message(kz_term:api_ne_binary(), non_neg_integer(), kz_json:object(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. -forward_message(AttachmentName, Length, Message, SrcBoxId, #mailbox{mailbox_number=BoxNum - ,mailbox_id=BoxId - ,timezone=Timezone - ,owner_id=OwnerId - ,transcribe_voicemail=MaybeTranscribe - ,after_notify_action=Action - ,media_extension=Extension - }=DestBox, Call) -> +forward_message(AttachmentName, Length, Message, SourceBoxId, DestinationBox, Call) -> + cf_util:start_task(fun forward_message_task/6 + ,[AttachmentName, Length, Message, SourceBoxId, DestinationBox] + ,Call + ), + _ = kapps_call_command:b_prompt(<<"vm-forward_confirmed">>, Call), + 'ok'. + +%%------------------------------------------------------------------------------ +%% @doc Forwards a message to another vmbox. +%% @end +%%------------------------------------------------------------------------------ +-spec forward_message_task(kz_term:api_ne_binary(), non_neg_integer(), kz_json:object(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. +forward_message_task(AttachmentName, Length, Message, SrcBoxId, #mailbox{mailbox_number=BoxNum + ,mailbox_id=BoxId + ,timezone=Timezone + ,owner_id=OwnerId + ,transcribe_voicemail=MaybeTranscribe + ,after_notify_action=Action + ,media_extension=Extension + }=DestBox, Call) -> NewMsgProps = props:filter_undefined( [{<<"Box-Id">>, BoxId} ,{<<"Owner-Id">>, OwnerId} @@ -1245,8 +1260,7 @@ forward_message(AttachmentName, Length, Message, SrcBoxId, #mailbox{mailbox_numb ] ), case kvm_message:forward_message(Call, Message, SrcBoxId, NewMsgProps) of - {'ok', NewCall} -> - _ = kapps_call_command:b_prompt(<<"vm-forward_confirmed">>, NewCall), + {'ok', _} -> send_mwi_update(DestBox); {'error', _, _Msg} -> lager:warning("failed to save forwarded voice mail message recorded media : ~p", [_Msg]) From 0fdd61e6478b645e4070a1e8ad9e6f11c7c4e895 Mon Sep 17 00:00:00 2001 From: Roger Neate Date: Fri, 16 Oct 2020 18:57:28 +0000 Subject: [PATCH 2/2] PISTON-1123: Deletes trailing whitespace. --- applications/callflow/src/module/cf_voicemail.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/callflow/src/module/cf_voicemail.erl b/applications/callflow/src/module/cf_voicemail.erl index 3a30b83e236..efb99a21cd4 100644 --- a/applications/callflow/src/module/cf_voicemail.erl +++ b/applications/callflow/src/module/cf_voicemail.erl @@ -1220,7 +1220,7 @@ maybe_forward(AttachmentName, Message, SourceBoxId, DestinationBox, Call, Msg, { forward_message(AttachmentName, Length, Message, SourceBoxId, DestinationBox, Call). %%------------------------------------------------------------------------------ -%% @doc Starts a task to asynchronously forward a message to another vmbox and +%% @doc Starts a task to asynchronously forward a message to another vmbox and %% plays a confirmation of the operation. %% @end %%------------------------------------------------------------------------------