./ct_report/coverage/mongoose_router_external.COVER.html

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