Skip to content

Commit

Permalink
Seek down the callflow for a dial-able pickup target (2600hz#5809)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirralev authored and jamesaimonetti committed Jun 27, 2019
1 parent 6889912 commit 85bfdba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions .aspell.en.prepl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ inputed inputted
compaired compared
asjust Adjust
accountdb account db
extention extension
dor dot
regexs regexps
listsing listing
Expand Down
2 changes: 1 addition & 1 deletion .aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ httpchk
escript
postpay
iso
DSAPublicKey
whitespaces
DSAPublicKey
UntilFun
Atka
jpg
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/doc/group_pickup_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Key | Description | Type | Default | Required | Support Level

### Usage

Currently the feature code for group pickup will lookup a device by SIP username or an extension that has a first child in the `flow` of `user`, `device`, `ring_group`, or `page_group`.
The feature code for group pickup will lookup a device by SIP username or an extension. The callflow for that extension is searched in a depth-first order until a target-able module is found (one of `user`, `device`, `ring_group`, or `page_group`). Once a suitable module is found, if there is an unanswered call ringing a targeted device it will be picked up.

#### Extension callflow

Expand Down
25 changes: 16 additions & 9 deletions applications/callflow/src/module/cf_group_pickup_feature.erl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ build_pickup_params(Number, <<"extension">>, Call) ->
{'ok', FlowDoc, 'false'} ->
Data = kz_json:get_json_value([<<"flow">>, <<"data">>], FlowDoc),
Module = kz_json:get_ne_binary_value([<<"flow">>, <<"module">>], FlowDoc),
params_from_data(Module, Data, Call);
ChildFlow = kz_json:get_json_value([<<"flow">>, <<"children">>, <<"_">>], FlowDoc),
params_from_data(Module, Data, ChildFlow);
{'ok', _FlowDoc, 'true'} ->
{'error', <<"no callflow with extension ", Number/binary>>};
{'error', _} = E -> E
Expand All @@ -107,22 +108,28 @@ build_pickup_params(_ ,'undefined', _) ->
build_pickup_params(_, Other, _) ->
{'error', <<Other/binary," not implemented">>}.

-spec params_from_data(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) ->
-spec params_from_data(kz_term:api_ne_binary(), kz_json:object(), kz_term:api_object()) ->
{'ok', kz_term:proplist()} |
{'error', kz_term:ne_binary()}.
params_from_data(<<"user">>, Data, _Call) ->
params_from_data(_, _, 'undefined') ->
{'error',<<"callflow not defined">>};
params_from_data(<<"user">>, Data, _Flow) ->
EndpointId = kz_json:get_ne_binary_value(<<"id">>, Data),
{'ok', [{<<"user_id">>, EndpointId}]};
params_from_data(<<"device">>, Data, _Call) ->
params_from_data(<<"device">>, Data, _Flow) ->
EndpointId = kz_json:get_ne_binary_value(<<"id">>, Data),
{'ok', [{<<"device_id">>, EndpointId}]};
params_from_data(<<"ring_group">>, Data, _Call) ->
params_from_data(<<"ring_group">>, Data, _Flow) ->
[Endpoint |_Endpoints] = kz_json:get_list_value(<<"endpoints">>, Data, []),
EndpointType = kz_json:get_ne_binary_value(<<"endpoint_type">>, Endpoint),
{'ok', [{<<EndpointType/binary, "_id">>, kz_doc:id(Endpoint)}]};
params_from_data(<<"page_group">>, Data, _Call) ->
params_from_data(<<"ring_group">>, Data, _Call);
params_from_data(<<"page_group">>, Data, _Flow) ->
params_from_data(<<"ring_group">>, Data, _Flow);
params_from_data('undefined', _, _) ->
{'error',<<"module not defined in callflow">>};
params_from_data(Other, _, _) ->
{'error',<<"module ", Other/binary, " not implemented">>}.
params_from_data(_Other, _, Flow) ->
lager:debug("skipping module ~p, looking at children", [_Other]),
Child = kz_json:get_json_value([<<"children">>, <<"_">>], Flow),
Data = kz_json:get_json_value([<<"data">>], Child),
Module = kz_json:get_ne_binary_value([<<"module">>], Child),
params_from_data(Module, Data, Child).

0 comments on commit 85bfdba

Please sign in to comment.