Skip to content

Commit

Permalink
WHISTLE-1028: make sure number is assigned to account we think we're …
Browse files Browse the repository at this point in the history
…processing
  • Loading branch information
James Aimonetti committed Mar 20, 2012
1 parent 4c0617d commit d828c31
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions whistle_apps/apps/trunkstore/src/ts_from_offnet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ routing_data(ToDID, AcctID) ->
,wh_json:get_value(<<"media_handling">>, AcctStuff)
]),


FailoverLocations = [
wh_json:get_value(<<"failover">>, DIDOptions)
,wh_json:get_value(<<"failover">>, SrvOptions)
Expand All @@ -308,8 +307,14 @@ routing_data(ToDID, AcctID) ->
Db = wnm_util:number_to_db_name(Num),
FL = case couch_mgr:open_doc(Db, Num) of
{ok, NumJObj} ->
?LOG("found ~s in ~s", [Num, Db]),
[wh_json:get_value(<<"failover">>, NumJObj) | FailoverLocations];
case wh_json:get_value(<<"pvt_assigned_to">>, NumJObj) =:= AcctID of
true ->
?LOG("found ~s in ~s", [Num, Db]),
[wh_json:get_value(<<"failover">>, NumJObj) | FailoverLocations];
false ->
?LOG("found ~s in ~s, but is for account ~s", [Num, Db, wh_json:get_value(<<"pvt_assigned_to">>, NumJObj)]),
FailoverLocations
end;
{error, _} ->
?LOG("failed to find ~s in ~s", [Num, Db]),
FailoverLocations
Expand Down

0 comments on commit d828c31

Please sign in to comment.