Skip to content

Commit

Permalink
KAZOO-240: process conference profiles config
Browse files Browse the repository at this point in the history
  • Loading branch information
James Aimonetti committed Apr 4, 2013
1 parent 396f9f0 commit 58f081a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ecallmgr/src/ecallmgr_fs_config.erl
Expand Up @@ -187,6 +187,7 @@ handle_config_req(Node, ID, _Conf) ->
freeswitch:fetch_reply(Node, ID, iolist_to_binary(Resp)).

handle_config_req(Node, ID, <<"conference.conf">>, Data) ->
put('callid', ID),
ConfConfig = props:get_value(<<"profile_name">>, Data, <<"default">>),
Cmd =
[{<<"Conference-Config">>, ConfConfig}
Expand All @@ -198,8 +199,8 @@ handle_config_req(Node, ID, <<"conference.conf">>, Data) ->
)
of
{'ok', Resp} ->
lager:debug("recv config resp: ~p", [Resp]),
{'ok', Xml} = ecallmgr_fs_xml:conference_resp_xml(Resp),
lager:debug("conference config xml: ~s", [Xml]),
Xml;
{'error', 'timeout'} ->
lager:debug("timed out waiting for conference config for ~s", [ConfConfig]),
Expand Down
17 changes: 11 additions & 6 deletions ecallmgr/src/ecallmgr_fs_xml.erl
Expand Up @@ -120,13 +120,18 @@ empty_response() ->

-spec conference_resp_xml(api_terms()) -> {'ok', iolist()}.
conference_resp_xml([_|_]=Resp) ->
{'ok', xmerl:export(conference_profiles_xml(props:get_value(<<"Profiles">>, Resp, wh_json:new())), 'fs_xml')};
Ps = props:get_value(<<"Profiles">>, Resp, wh_json:new()),
ProfilesEl = conference_profiles_xml(Ps),
{'ok', xmerl:export([ProfilesEl], 'fs_xml')};
conference_resp_xml(Resp) ->
{'ok', xmerl:export(conference_profiles_xml(wh_json:get_value(<<"Profiles">>, Resp, wh_json:new())), 'fs_xml')}.

conference_profiles_xml(Profiles) ->
ProfileEls = [conference_profile_xml(Name, Params) || {Name, Params} <- wh_json:to_proplist(Profiles)],
profiles_el(ProfileEls).
Ps = wh_json:get_value(<<"Profiles">>, Resp, wh_json:new()),
ProfilesEl = conference_profiles_xml(Ps),
{'ok', xmerl:export([ProfilesEl], 'fs_xml')}.

conference_profiles_xml(Profiles) when is_list(Profiles) ->
ProfileEls = [conference_profile_xml(Name, Params) || {Name, Params} <- Profiles],
profiles_el(ProfileEls);
conference_profiles_xml(Profiles) -> conference_profiles_xml(wh_json:to_proplist(Profiles)).

conference_profile_xml(Name, Params) ->
ParamEls = [param_el(K, V) || {K, V} <- wh_json:to_proplist(Params)],
Expand Down
7 changes: 4 additions & 3 deletions whistle_apps/apps/conference/src/conf_discovery.erl
Expand Up @@ -89,9 +89,10 @@ handle_config_req(JObj, _Props) ->
lager:debug("looking up conference config '~s'", [ConfigName]),
case whapps_config:get(<<"conferences">>, ConfigName) of
'undefined' -> lager:debug("no config defined");
Profiles ->
lager:debug("profiles found: ~p", [Profiles]),
Resp = [{<<"Profiles">>, Profiles}
Profile ->
lager:debug("profile ~s found", [ConfigName]),
Resp = [{<<"Profiles">>, wh_json:from_list([{ConfigName, Profile}])}
,{<<"Msg-ID">>, wh_json:get_value(<<"Msg-ID">>, JObj)}
| wh_api:default_headers(?APP_NAME, ?APP_VERSION)
],
wapi_conference:publish_config_resp(wh_json:get_value(<<"Server-ID">>, JObj)
Expand Down

0 comments on commit 58f081a

Please sign in to comment.