From 92aa60d726f7c6971b3fb8ebc4911e8b37ab5a35 Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 9 Apr 2020 07:07:40 +0000 Subject: [PATCH] determine conference-control-node * if the conference is initiated directly in freeswitch, we need to assign a node so that conference events are emitted --- .../ecallmgr/src/ecallmgr_fs_conferences.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/applications/ecallmgr/src/ecallmgr_fs_conferences.erl b/applications/ecallmgr/src/ecallmgr_fs_conferences.erl index 8456f489221..8135a64275c 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_conferences.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_conferences.erl @@ -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 @@ -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