Skip to content

Commit

Permalink
make clear that the template is ignored, not disabled (#6178)
Browse files Browse the repository at this point in the history
  • Loading branch information
icehess authored and lazedo committed Dec 4, 2019
1 parent 820d8b2 commit 92b4871
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions applications/teletype/src/templates/teletype_transaction.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ handle_req(JObj, 'true') ->
ReqData =
kz_json:set_value(<<"user">>, teletype_util:find_account_admin(AccountId), DataJObj),

case kz_json:is_true(<<"success">>, DataJObj) %% check if it's for transaction success template
andalso teletype_util:is_notice_enabled(AccountId, JObj, ?TEMPLATE_ID)
of
case processability(kz_json:is_true(<<"success">>, DataJObj), JObj) of
'ignore' -> teletype_util:notification_ignored(?TEMPLATE_ID);
'false' -> teletype_util:notification_disabled(DataJObj, ?TEMPLATE_ID);
'true' -> process_req(kz_json:merge_jobjs(DataJObj, ReqData), ?TEMPLATE_ID)
end.

-spec processability(boolean(), kz_json:object()) -> 'ignore' | boolean().
processability('true', JObj) ->
%% it's for transaction template
teletype_util:is_notice_enabled(kz_json:get_value(<<"Account-ID">>, JObj), JObj, ?TEMPLATE_ID);
processability('false', _) ->
'ignore'.

-spec process_req(kz_json:object(), kz_term:ne_binary()) -> template_response().
process_req(DataJObj, TemplateId) ->
Macros = [{<<"system">>, teletype_util:system_params()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ handle_req(JObj, 'true') ->

ReqData =
kz_json:set_value(<<"user">>, teletype_util:find_account_admin(AccountId), DataJObj),
case kz_json:is_false(<<"success">>, DataJObj) %% check if it's for transaction failed template
andalso teletype_util:is_notice_enabled(AccountId, JObj, ?TEMPLATE_ID)
of
case processability(kz_json:is_false(<<"success">>, DataJObj), JObj) of
'ignore' -> teletype_util:notification_ignored(?TEMPLATE_ID);
'false' -> teletype_util:notification_disabled(DataJObj, ?TEMPLATE_ID);
'true' -> teletype_transaction:process_req(kz_json:merge_jobjs(DataJObj, ReqData), ?TEMPLATE_ID)
end.

-spec processability(boolean(), kz_json:object()) -> 'ignore' | boolean().
processability('true', JObj) ->
%% it's for transaction failed template
teletype_util:is_notice_enabled(kz_json:get_value(<<"Account-ID">>, JObj), JObj, ?TEMPLATE_ID);
processability('false', _) ->
'ignore'.

0 comments on commit 92b4871

Please sign in to comment.