Skip to content

Commit

Permalink
Merge branch 'v1.44'
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Dec 22, 2011
2 parents 9f0d968 + 46573e9 commit 38a5fdf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ecallmgr/src/ecallmgr_call_command.erl
Expand Up @@ -257,7 +257,7 @@ get_fs_app(Node, UUID, JObj, <<"bridge">>) ->
put(callid, UUID),
S ! {self(), (catch get_bridge_endpoint(EP))}
end)
|| {_, EP} <- orddict:to_list(orddict:from_list(KeyedEPs))]
|| {_, EP} <- props:unique(KeyedEPs)]
], D =/= ""],
Generators = [fun(DP) ->
case wh_json:get_integer_value(<<"Timeout">>, JObj) of
Expand Down
33 changes: 22 additions & 11 deletions lib/whistle-1.0.0/src/props.erl
Expand Up @@ -11,6 +11,7 @@

-export([get_value/2, get_value/3, delete/2, is_defined/2]).
-export([get_keys/1]).
-export([unique/1]).

-include_lib("whistle/include/wh_types.hrl").

Expand All @@ -29,15 +30,15 @@ get_value(Key, {struct, Prop}, Def) ->
get_value(Key, Prop, Def);
get_value(Key, Prop, Default) ->
case lists:keyfind(Key, 1, Prop) of
false ->
case lists:member(Key, Prop) of
true -> true;
false -> Default
end;
{Key, V} -> % only return V if a two-tuple is found
V;
Other when is_tuple(Other) -> % otherwise return the default
Default
false ->
case lists:member(Key, Prop) of
true -> true;
false -> Default
end;
{Key, V} -> % only return V if a two-tuple is found
V;
Other when is_tuple(Other) -> % otherwise return the default
Default
end.

-spec get_keys/1 :: (Prop) -> [term(),...] | [] when
Expand All @@ -56,6 +57,16 @@ delete(K, Prop) ->
Prop :: proplist().
is_defined(Key, Prop) ->
case lists:keyfind(Key, 1, Prop) of
{Key,_} -> true;
_ -> false
{Key,_} -> true;
_ -> false
end.

-spec unique/1 :: (proplist()) -> proplist().
unique(List) ->
unique(List, []).

-spec unique/2 :: (proplist(), proplist()) -> proplist().
unique([], Uniques) ->
lists:reverse(Uniques);
unique([{Key, _}=H|T], Uniques) ->
unique(lists:keydelete(Key, 1, T), [H|Uniques]).

0 comments on commit 38a5fdf

Please sign in to comment.