Skip to content

Commit

Permalink
WHISTLE-1916: if the classifier is tollfree and inbound skip authz
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Feb 2, 2013
1 parent 7832b74 commit 88bb667
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions whistle_apps/apps/jonny5/src/j5_authz_req.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ handle_req(JObj, Props) ->
,fun maybe_flat_rate/3
,fun maybe_per_minute/3
,fun maybe_soft_limit/3
,fun maybe_emergency/3
,fun maybe_no_limits/3
],

send_resp(JObj
Expand Down Expand Up @@ -85,16 +85,23 @@ maybe_soft_limit({error, _}=E, Limits, JObj) ->
end;
maybe_soft_limit(Else, _, _) -> Else.

-spec maybe_emergency/3 :: (authz_resp(), #limits{}, wh_json:json_object()) -> authz_resp().
maybe_emergency({error, _}=E, _, JObj) ->
-spec maybe_no_limits/3 :: (authz_resp(), #limits{}, wh_json:json_object()) -> authz_resp().
maybe_no_limits({error, _}=E, _, JObj) ->
[Number, _] = binary:split(wh_json:get_value(<<"Request">>, JObj), <<"@">>),
case wnm_util:classify_number(Number) of
<<"emergency">> ->
lager:debug("allowing emergency call", []),
{ok, limits_disabled};
<<"tollfree">> ->
case wh_json:get_value(<<"Call-Direction">>, JObj) of
<<"inbound">> ->
lager:debug("allowing inbound tollfree call", []),
{ok, limits_disabled};
_Else -> E
end;
_Else -> E
end;
maybe_emergency(Else, _, _) -> Else.
maybe_no_limits(Else, _, _) -> Else.

-spec should_soft_limit/2 :: (ne_binary(), #limits{}) -> boolean().
should_soft_limit(<<"outbound">>, #limits{soft_limit_outbound=true}) ->
Expand Down

0 comments on commit 88bb667

Please sign in to comment.