1 |
|
%%%------------------------------------------------------------------- |
2 |
|
%%% @doc |
3 |
|
%%% Part of a routing chain; does only filtering - uses hooks to check |
4 |
|
%%% if the message should be routed at all. This one should be the first |
5 |
|
%%% module in chain. |
6 |
|
%%% @end |
7 |
|
%%%------------------------------------------------------------------- |
8 |
|
-module(mongoose_router_global). |
9 |
|
-author('bartlomiej.gorny@erlang-solutions.com'). |
10 |
|
|
11 |
|
-behaviour(xmpp_router). |
12 |
|
|
13 |
|
%% xmpp_router callback |
14 |
|
-export([filter/4, route/4]). |
15 |
|
|
16 |
|
filter(OrigFrom, OrigTo, OrigAcc, OrigPacket) -> |
17 |
|
%% Filter globally |
18 |
50333 |
case mongoose_hooks:filter_packet({OrigFrom, OrigTo, OrigAcc, OrigPacket}) of |
19 |
|
{From, To, Acc, Packet} -> |
20 |
49947 |
{From, To, Acc, Packet}; |
21 |
|
drop -> |
22 |
386 |
drop |
23 |
|
end. |
24 |
|
|
25 |
|
route(From, To, Acc, Packet) -> |
26 |
49947 |
{From, To, Acc, Packet}. |