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