Skip to content

Commit

Permalink
determine conference-control-node (#6457)
Browse files Browse the repository at this point in the history
* if the conference is initiated directly
  in freeswitch, we need to assign a node
  so that conference events are emitted
  • Loading branch information
lazedo authored Apr 9, 2020
1 parent a999bfc commit 2d8b4da
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion applications/ecallmgr/src/ecallmgr_fs_conferences.erl
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ conference_from_props(Props, Node) ->

-spec conference_from_props(kz_term:proplist(), atom(), conference()) -> conference().
conference_from_props(Props, Node, Conference) ->
CtrlNode = kz_term:to_atom(kzd_freeswitch:ccv(Props, <<"Ecallmgr-Node">>), 'true'),
CtrlNode = conference_control_node(Node, Props),
AccountId = find_account_id(Props),

Conference#conference{node = Node
Expand All @@ -459,6 +459,19 @@ conference_from_props(Props, Node, Conference) ->
,control_node = CtrlNode
}.

conference_control_node(Node, Props) ->
CtrlNode = kz_term:to_atom(kzd_freeswitch:ccv(Props, <<"Ecallmgr-Node">>), 'true'),
conference_control_node(Node, Props, CtrlNode).

conference_control_node(Node, Props, undefined) ->
UUID = kzd_freeswitch:call_id(Props),
CtrlNode = kz_nodes:whapp_oldest_node(ecallmgr),
ToSet = [{<<"Ecallmgr-Node">>, kz_term:to_binary(CtrlNode)}],
ecallmgr_fs_command:bg_set(Node, UUID, ToSet),
CtrlNode;
conference_control_node(_Node, _Props, Value) ->
Value.

-spec find_account_id(kzd_freeswitch:doc()) -> kz_term:api_ne_binary().
find_account_id(Props) ->
case kzd_freeswitch:account_id(Props) of
Expand Down

0 comments on commit 2d8b4da

Please sign in to comment.