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 |
175 |
{OrigFrom, OrigTo, OrigAcc, OrigPacket}. |
21 |
|
|
22 |
|
route(From, To, Acc0, Packet) -> |
23 |
175 |
LDstDomain = To#jid.lserver, |
24 |
175 |
case mongoose_component:lookup_component(LDstDomain, node()) of |
25 |
|
[] -> |
26 |
175 |
{From, To, Acc0, Packet}; |
27 |
|
[#external_component{handler = Handler}] -> |
28 |
:-( |
Acc1 = mongoose_local_delivery:do_route(From, To, Acc0, Packet, Handler), |
29 |
:-( |
{done, Acc1} |
30 |
|
end. |