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 |
50174 |
{From, To, Acc, Packet}. |
19 |
|
|
20 |
|
route(From, To, Acc0, Packet) -> |
21 |
50366 |
LDstDomain = To#jid.lserver, |
22 |
50366 |
case mongoose_router:lookup_route(LDstDomain) of |
23 |
341 |
no_route -> {From, To, Acc0, Packet}; |
24 |
|
Handler -> |
25 |
50025 |
Acc1 = mongoose_local_delivery:do_route(From, To, Acc0, Packet, Handler), |
26 |
50021 |
{done, Acc1} |
27 |
|
end. |