Skip to content

Commit

Permalink
HELP-31124: fix check type and add numbers as reserved (2600hz#3978)
Browse files Browse the repository at this point in the history
Conflicts:
	applications/crossbar/src/modules/cb_resources.erl
  • Loading branch information
k-anderson authored and fenollp committed Jul 20, 2017
1 parent ecc9250 commit 1ac7e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions applications/crossbar/src/modules/cb_jobs_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ maybe_create_number(Job, AccountId, AuthAccountId, CarrierModule, Number) ->
create_number(Job, AccountId, AuthAccountId, CarrierModule, DID) ->
Options = [{'assign_to', AccountId}
,{'auth_by', AuthAccountId}
,{'state', ?NUMBER_STATE_AVAILABLE}
,{'state', ?NUMBER_STATE_RESERVED}
,{'public_fields', build_number_properties(Job)}
,{'dry_run', 'false'}
,{'module_name', CarrierModule}
Expand All @@ -174,7 +174,7 @@ create_number(Job, AccountId, AuthAccountId, CarrierModule, DID) ->
PhoneNumber = knm_number:phone_number(Number),
lager:debug("successfully created number ~s for account ~s"
,[knm_phone_number:number(PhoneNumber), AccountId]),
update_status(kz_json:set_value([?KEY_SUCCESS, Number]
update_status(kz_json:set_value([?KEY_SUCCESS, knm_phone_number:number(PhoneNumber)]
,knm_phone_number:to_public_json(PhoneNumber)
,Job
)
Expand All @@ -184,6 +184,8 @@ create_number(Job, AccountId, AuthAccountId, CarrierModule, DID) ->
update_with_failure(Job, AccountId, DID, Failure, JObj)
catch
E:_R ->
ST = erlang:get_stacktrace(),
kz_util:log_stacktrace(ST),
lager:debug("exception creating number ~s for account ~s: ~s: ~p"
,[DID, AccountId, E, _R]),
update_status(kz_json:set_value([<<"errors">>, DID]
Expand Down
4 changes: 2 additions & 2 deletions applications/crossbar/src/modules/cb_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ read(Id, Context) ->
-spec read_job(cb_context:context(), ne_binary()) -> cb_context:context().
read_job(Context, ?MATCH_MODB_PREFIX(Year,Month,_) = JobId) ->
Modb = cb_context:account_modb(Context, kz_term:to_integer(Year), kz_term:to_integer(Month)),
leak_job_fields(crossbar_doc:load(JobId, cb_context:set_account_db(Context, Modb), ?TYPE_CHECK_OPTION(<<"resource">>)));
leak_job_fields(crossbar_doc:load(JobId, cb_context:set_account_db(Context, Modb), ?TYPE_CHECK_OPTION(<<"resource_job">>)));
read_job(Context, ?MATCH_MODB_PREFIX_M1(Year,Month,_) = JobId) ->
Modb = cb_context:account_modb(Context, kz_term:to_integer(Year), kz_term:to_integer(Month)),
leak_job_fields(crossbar_doc:load(JobId, cb_context:set_account_db(Context, Modb), ?TYPE_CHECK_OPTION(<<"resource">>)));
leak_job_fields(crossbar_doc:load(JobId, cb_context:set_account_db(Context, Modb), ?TYPE_CHECK_OPTION(<<"resource_job">>)));
read_job(Context, JobId) ->
lager:debug("invalid job id format: ~s", [JobId]),
crossbar_util:response_bad_identifier(JobId, Context).
Expand Down

0 comments on commit 1ac7e09

Please sign in to comment.