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