./ct_report/coverage/mongoose_router_external_localnode.COVER.html

1 %%%-------------------------------------------------------------------
2 %%% @doc
3 %%% Part of a routing chain; checks if there is an external component
4 %%% registered for the domain on this node and directs the message there if there is,
5 %%% otherwise just passes it on.
6 %%% @end
7 %%%-------------------------------------------------------------------
8 -module(mongoose_router_external_localnode).
9 -author('bartlomiej.gorny@erlang-solutions.com').
10
11 -behaviour(xmpp_router).
12
13 -include("jlib.hrl").
14 -include("external_component.hrl").
15
16 %% xmpp_router callback
17 -export([filter/4, route/4]).
18
19 filter(OrigFrom, OrigTo, OrigAcc, OrigPacket) ->
20 340 {OrigFrom, OrigTo, OrigAcc, OrigPacket}.
21
22 route(From, To, Acc0, Packet) ->
23 340 LDstDomain = To#jid.lserver,
24 340 case mongoose_component:lookup_component(LDstDomain, node()) of
25 [] ->
26 327 {From, To, Acc0, Packet};
27 [#external_component{handler = Handler}] ->
28 13 Acc1 = mongoose_local_delivery:do_route(From, To, Acc0, Packet, Handler),
29 13 {done, Acc1}
30 end.
Line Hits Source