1 |
|
%%%------------------------------------------------------------------- |
2 |
|
%%% @doc |
3 |
|
%%% Part of a routing chain: searches for a route registered for the domain, |
4 |
|
%%% forwards the message there, or passes on. |
5 |
|
%%% @end |
6 |
|
%%%------------------------------------------------------------------- |
7 |
|
-module(mongoose_router_localdomain). |
8 |
|
-author('bartlomiej.gorny@erlang-solutions.com'). |
9 |
|
|
10 |
|
-behaviour(xmpp_router). |
11 |
|
|
12 |
|
-include("jlib.hrl"). |
13 |
|
|
14 |
|
%% xmpp_router callback |
15 |
|
-export([filter/4, route/4]). |
16 |
|
|
17 |
|
filter(From, To, Acc, Packet) -> |
18 |
45953 |
{From, To, Acc, Packet}. |
19 |
|
|
20 |
|
route(From, To, Acc0, Packet) -> |
21 |
46136 |
LDstDomain = To#jid.lserver, |
22 |
46136 |
case mongoose_router:lookup_route(LDstDomain) of |
23 |
332 |
no_route -> {From, To, Acc0, Packet}; |
24 |
|
Handler -> |
25 |
45804 |
Acc1 = mongoose_local_delivery:do_route(From, To, Acc0, Packet, Handler), |
26 |
45800 |
{done, Acc1} |
27 |
|
end. |