Skip to content

Commit

Permalink
KAZOO-5492: declare exchange to handle check_sync messages (2600hz#3726)
Browse files Browse the repository at this point in the history
* formatting

* KAZOO-5492: declare exchange to handle check_sync messages

* KAZOO-5492: crossbar does not directly rely on this exchange

* KAZOO-5492: keep declaring kapi_switch exchange in crossbar cause it`s actually used in there
  • Loading branch information
fenollp authored and k-anderson committed May 30, 2017
1 parent 205db16 commit 78d399d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
10 changes: 5 additions & 5 deletions applications/ecallmgr/src/ecallmgr_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ start(_StartType, _StartArgs) ->
-spec request(kz_nodes:request_acc()) -> kz_nodes:request_acc().
request(Acc) ->
Servers = [{kz_term:to_binary(Server)
,kz_json:set_values([{<<"Startup">>, Started}
,{<<"Interface">>, kz_json:from_list(ecallmgr_fs_node:interface(Server))}
]
,kz_json:new()
)
,kz_json:from_list_recursive(
[{<<"Startup">>, Started}
,{<<"Interface">>, [ecallmgr_fs_node:interface(Server)]}
])
}
|| {Server, Started} <- ecallmgr_fs_nodes:connected('true')
],
Expand Down Expand Up @@ -69,6 +68,7 @@ declare_exchanges() ->
_ = kapi_route:declare_exchanges(),
_ = kapi_sysconf:declare_exchanges(),
_ = kapi_sms:declare_exchanges(),
_ = kapi_switch:declare_exchanges(),
_ = kapi_presence:declare_exchanges(),
kapi_self:declare_exchanges().

Expand Down
12 changes: 4 additions & 8 deletions applications/ecallmgr/src/ecallmgr_fs_notify.erl
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,28 @@ resp_to_probe(State, User, Realm) ->
check_sync_api(JObj, _Props) ->
'true' = kapi_switch:check_sync_v(JObj),
kz_util:put_callid(JObj),
check_sync(kapi_switch:check_sync_username(JObj)
,kapi_switch:check_sync_realm(JObj)
).
check_sync(kapi_switch:check_sync_username(JObj), kapi_switch:check_sync_realm(JObj)).

-spec check_sync(ne_binary(), ne_binary()) -> 'ok'.
check_sync(Username, Realm) ->
lager:info("looking up registration information for ~s@~s", [Username, Realm]),
case ecallmgr_registrar:lookup_registration(Realm, Username) of
{'error', 'not_found'} ->
lager:warning("failed to find contact for ~s@~s, not sending check-sync", [Username, Realm]);
lager:warning("failed to find contact ~s@~s, not sending check-sync", [Username, Realm]);
{'ok', Registration} ->
Contact = kz_json:get_first_defined([<<"Bridge-RURI">>, <<"Contact">>], Registration),
[Node|_] = kz_term:shuffle_list(ecallmgr_fs_nodes:connected()),
lager:info("calling check sync on ~s for ~s@~s and contact ~s", [Node, Username, Realm, Contact]),
case ensure_contact_user(Contact, Username, Realm) of
'undefined' ->
lager:error("invalid contact : ~p : ~p", [Contact, Registration]);
lager:error("invalid contact ~p: ~p", [Contact, Registration]);
Valid -> send_check_sync(Node, Username, Realm, Valid)
end
end.

-spec send_check_sync(atom(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'.
send_check_sync(Node, Username, Realm, Contact) ->
To = kzsip_uri:uri(#uri{user=Username, domain=Realm}),
From = kzsip_uri:uri(#uri{user=Username, domain=Realm}),
AOR = kzsip_uri:ruri(#uri{user=Username, domain=Realm}),
AOR = To = From = kzsip_uri:ruri(#uri{user=Username, domain=Realm}),
SIPHeaders = <<"X-KAZOO-AOR : ", AOR/binary, "\r\n">>,
Headers = [{"profile", ?DEFAULT_FS_PROFILE}
,{"contact-uri", Contact}
Expand Down
3 changes: 2 additions & 1 deletion core/kazoo_amqp/src/api/kapi_conf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ get_value(JObj, Key) ->
kz_json:get_value(Key, JObj).

%%--------------------------------------------------------------------
%% @doc Format a call event from the switch for the listener
%% @doc
%% Format a call event from the switch for the listener
%% Takes proplist, creates JSON string or error
%% @end
%%--------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions core/kazoo_amqp/src/api/kz_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,7 @@ values_check_all(Prop, {Key, V}) ->
'undefined' -> 'true'; % isn't defined in Prop, has_all will error if req'd
V -> 'true';
_Val ->
lager:debug("API key '~s' value '~p' is not '~p'"
,[Key, _Val, V]
),
lager:debug("API key '~s' value '~p' is not '~p'", [Key, _Val, V]),
'false'
end.

Expand Down
9 changes: 5 additions & 4 deletions core/kazoo_caches/src/kz_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
-include("kz_caches.hrl").

-define(SERVER, ?MODULE).
-define(EXPIRES, ?SECONDS_IN_HOUR). %% an hour
-define(EXPIRES, ?SECONDS_IN_HOUR).
-define(EXPIRE_PERIOD, 10 * ?MILLISECONDS_IN_SECOND).
-define(EXPIRE_PERIOD_MSG, 'expire_cache_objects').
-define(DEFAULT_WAIT_TIMEOUT, 5).
Expand All @@ -65,7 +65,7 @@
-type store_options() :: [{'origin', origin_tuple() | origin_tuples()} |
{'expires', kz_timeout()} |
{'callback', 'undefined' | callback_fun()}
] | [].
].
-export_type([store_options/0]).

-record(state, {name :: atom()
Expand Down Expand Up @@ -108,7 +108,8 @@ start_link(Name, ExpirePeriod, Props) ->
BindingProps ->
lager:debug("started new cache process (gen_listener): ~s", [Name]),
Bindings = [{'conf', ['federate' | P]} || P <- maybe_add_db_binding(BindingProps)],
gen_listener:start_link({'local', Name}, ?MODULE
gen_listener:start_link({'local', Name}
,?MODULE
,[{'bindings', Bindings}
,{'responders', ?RESPONDERS}
,{'queue_name', ?QUEUE_NAME}
Expand Down Expand Up @@ -597,7 +598,7 @@ handle_event(JObj, #state{tab=Tab}=State) ->
of
'true' -> handle_document_change(JObj, State);
'false' when V -> 'ok';
'false' -> lager:error("payload invalid for kapi_conf : ~p", [JObj])
'false' -> lager:error("payload invalid for kapi_conf: ~p", [JObj])
end,
'ignore'.

Expand Down

0 comments on commit 78d399d

Please sign in to comment.