26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Convert to exmpp.

SVN Revision: 1393
This commit is contained in:
Jean-Sébastien Pédron 2008-07-01 07:49:57 +00:00
parent 06965000a5
commit 87218e1447
2 changed files with 144 additions and 88 deletions

View File

@ -1,3 +1,7 @@
2008-07-01 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/ejabberd_sm.erl: Convert to exmpp.
2008-06-30 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-06-30 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/Makefile.in: Remove the -I flag for exmpp includes; the * src/Makefile.in: Remove the -I flag for exmpp includes; the

View File

@ -56,8 +56,9 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]). terminate/2, code_change/3]).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl").
-include("ejabberd_ctl.hrl"). -include("ejabberd_ctl.hrl").
-record(session, {sid, usr, us, priority, info}). -record(session, {sid, usr, us, priority, info}).
@ -66,6 +67,20 @@
%% default value for the maximum number of user connections %% default value for the maximum number of user connections
-define(MAX_USER_SESSIONS, infinity). -define(MAX_USER_SESSIONS, infinity).
% These are the namespace already declared by the stream opening. This is
% used at serialization time.
-define(DEFAULT_NS, ?NS_JABBER_CLIENT).
-define(PREFIXED_NS, [
{?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx}
]).
% XXX OLD FORMAT: Re-include jlib.hrl (after clean-up).
-record(iq, {id = "",
type,
xmlns = "",
lang = "",
sub_el}).
%%==================================================================== %%====================================================================
%% API %% API
%%==================================================================== %%====================================================================
@ -76,7 +91,12 @@
start_link() -> start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
route(From, To, Packet) -> route(FromOld, ToOld, PacketOld) ->
% XXX OLD FORMAT: From, To, Packet.
From = jlib:from_old_jid(FromOld),
To = jlib:from_old_jid(ToOld),
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
[?DEFAULT_NS], ?PREFIXED_NS),
case catch do_route(From, To, Packet) of case catch do_route(From, To, Packet) of
{'EXIT', Reason} -> {'EXIT', Reason} ->
?ERROR_MSG("~p~nwhen processing: ~p", ?ERROR_MSG("~p~nwhen processing: ~p",
@ -88,9 +108,11 @@ route(From, To, Packet) ->
open_session(SID, User, Server, Resource, Info) -> open_session(SID, User, Server, Resource, Info) ->
set_session(SID, User, Server, Resource, undefined, Info), set_session(SID, User, Server, Resource, undefined, Info),
check_for_sessions_to_replace(User, Server, Resource), check_for_sessions_to_replace(User, Server, Resource),
JID = jlib:make_jid(User, Server, Resource), JID = exmpp_jid:make_jid(User, Server, Resource),
ejabberd_hooks:run(sm_register_connection_hook, JID#jid.lserver, % XXX OLD FORMAT: JID.
[SID, JID, Info]). JIDOld = jlib:to_old_jid(JID),
ejabberd_hooks:run(sm_register_connection_hook, JID#jid.ldomain,
[SID, JIDOld, Info]).
close_session(SID, User, Server, Resource) -> close_session(SID, User, Server, Resource) ->
Info = case mnesia:dirty_read({session, SID}) of Info = case mnesia:dirty_read({session, SID}) of
@ -101,9 +123,11 @@ close_session(SID, User, Server, Resource) ->
mnesia:delete({session, SID}) mnesia:delete({session, SID})
end, end,
mnesia:sync_dirty(F), mnesia:sync_dirty(F),
JID = jlib:make_jid(User, Server, Resource), JID = exmpp_jid:make_jid(User, Server, Resource),
ejabberd_hooks:run(sm_remove_connection_hook, JID#jid.lserver, % XXX OLD FORMAT: JID.
[SID, JID, Info]). JIDOld = jlib:to_old_jid(JID),
ejabberd_hooks:run(sm_remove_connection_hook, JID#jid.ldomain,
[SID, JIDOld, Info]).
check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) -> check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) ->
case ejabberd_auth:is_user_exists(User, Server) of case ejabberd_auth:is_user_exists(User, Server) of
@ -114,19 +138,19 @@ check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) ->
end. end.
bounce_offline_message(From, To, Packet) -> bounce_offline_message(From, To, Packet) ->
Err = jlib:make_error_reply(Packet, ?ERR_SERVICE_UNAVAILABLE), Err = exmpp_stanza:reply_with_error(Packet, 'service-unavailable'),
ejabberd_router:route(To, From, Err), ejabberd_router:route(To, From, Err),
stop. stop.
disconnect_removed_user(User, Server) -> disconnect_removed_user(User, Server) ->
ejabberd_sm:route(jlib:make_jid("", "", ""), ejabberd_sm:route(#jid{},
jlib:make_jid(User, Server, ""), exmpp_jid:make_bare_jid(User, Server),
{xmlelement, "broadcast", [], #xmlel{name = 'broadcast',
[{exit, "User removed"}]}). children = [{exit, "User removed"}]}).
get_user_resources(User, Server) -> get_user_resources(User, Server) ->
LUser = jlib:nodeprep(User), LUser = exmpp_stringprep:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_index_read(session, US, #session.us) of case catch mnesia:dirty_index_read(session, US, #session.us) of
{'EXIT', _Reason} -> {'EXIT', _Reason} ->
@ -136,9 +160,9 @@ get_user_resources(User, Server) ->
end. end.
get_user_ip(User, Server, Resource) -> get_user_ip(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = exmpp_stringprep:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = exmpp_stringprep:resourceprep(Resource),
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
case mnesia:dirty_index_read(session, USR, #session.usr) of case mnesia:dirty_index_read(session, USR, #session.usr) of
[] -> [] ->
@ -149,9 +173,9 @@ get_user_ip(User, Server, Resource) ->
end. end.
get_user_info(User, Server, Resource) -> get_user_info(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = exmpp_stringprep:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = exmpp_stringprep:resourceprep(Resource),
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
case mnesia:dirty_index_read(session, USR, #session.usr) of case mnesia:dirty_index_read(session, USR, #session.usr) of
[] -> [] ->
@ -166,23 +190,23 @@ get_user_info(User, Server, Resource) ->
set_presence(SID, User, Server, Resource, Priority, Presence, Info) -> set_presence(SID, User, Server, Resource, Priority, Presence, Info) ->
set_session(SID, User, Server, Resource, Priority, Info), set_session(SID, User, Server, Resource, Priority, Info),
ejabberd_hooks:run(set_presence_hook, jlib:nameprep(Server), ejabberd_hooks:run(set_presence_hook, exmpp_stringprep:nameprep(Server),
[User, Server, Resource, Presence]). [User, Server, Resource, Presence]).
unset_presence(SID, User, Server, Resource, Status, Info) -> unset_presence(SID, User, Server, Resource, Status, Info) ->
set_session(SID, User, Server, Resource, undefined, Info), set_session(SID, User, Server, Resource, undefined, Info),
ejabberd_hooks:run(unset_presence_hook, jlib:nameprep(Server), ejabberd_hooks:run(unset_presence_hook, exmpp_stringprep:nameprep(Server),
[User, Server, Resource, Status]). [User, Server, Resource, Status]).
close_session_unset_presence(SID, User, Server, Resource, Status) -> close_session_unset_presence(SID, User, Server, Resource, Status) ->
close_session(SID, User, Server, Resource), close_session(SID, User, Server, Resource),
ejabberd_hooks:run(unset_presence_hook, jlib:nameprep(Server), ejabberd_hooks:run(unset_presence_hook, exmpp_stringprep:nameprep(Server),
[User, Server, Resource, Status]). [User, Server, Resource, Status]).
get_session_pid(User, Server, Resource) -> get_session_pid(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = exmpp_stringprep:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = exmpp_stringprep:resourceprep(Resource),
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
case catch mnesia:dirty_index_read(session, USR, #session.usr) of case catch mnesia:dirty_index_read(session, USR, #session.usr) of
[#session{sid = {_, Pid}}] -> Pid; [#session{sid = {_, Pid}}] -> Pid;
@ -204,7 +228,7 @@ dirty_get_my_sessions_list() ->
['$_']}]). ['$_']}]).
get_vh_session_list(Server) -> get_vh_session_list(Server) ->
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
mnesia:dirty_select( mnesia:dirty_select(
session, session,
[{#session{usr = '$1', _ = '_'}, [{#session{usr = '$1', _ = '_'},
@ -287,7 +311,12 @@ handle_cast(_Msg, State) ->
%% {stop, Reason, State} %% {stop, Reason, State}
%% Description: Handling all non call/cast messages %% Description: Handling all non call/cast messages
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
handle_info({route, From, To, Packet}, State) -> handle_info({route, FromOld, ToOld, PacketOld}, State) ->
% XXX OLD FORMAT: From, To, Packet.
From = jlib:from_old_jid(FromOld),
To = jlib:from_old_jid(ToOld),
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
[?DEFAULT_NS], ?PREFIXED_NS),
case catch do_route(From, To, Packet) of case catch do_route(From, To, Packet) of
{'EXIT', Reason} -> {'EXIT', Reason} ->
?ERROR_MSG("~p~nwhen processing: ~p", ?ERROR_MSG("~p~nwhen processing: ~p",
@ -339,9 +368,9 @@ code_change(_OldVsn, State, _Extra) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
set_session(SID, User, Server, Resource, Priority, Info) -> set_session(SID, User, Server, Resource, Priority, Info) ->
LUser = jlib:nodeprep(User), LUser = exmpp_stringprep:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = exmpp_stringprep:resourceprep(Resource),
US = {LUser, LServer}, US = {LUser, LServer},
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
F = fun() -> F = fun() ->
@ -371,45 +400,49 @@ clean_table_from_bad_node(Node) ->
do_route(From, To, Packet) -> do_route(From, To, Packet) ->
?DEBUG("session manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n", ?DEBUG("session manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
[From, To, Packet, 8]), [From, To, Packet, 8]),
#jid{user = User, server = Server, #jid{node = User, domain = Server,
luser = LUser, lserver = LServer, lresource = LResource} = To, lnode = LUser, ldomain = LServer, lresource = LResource} = To,
{xmlelement, Name, Attrs, _Els} = Packet, % XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
case LResource of case LResource of
"" -> undefined ->
case Name of case Packet of
"presence" -> _ when ?IS_PRESENCE(Packet) ->
{Pass, _Subsc} = {Pass, _Subsc} =
case xml:get_attr_s("type", Attrs) of case exmpp_presence:get_type(Packet) of
"subscribe" -> 'subscribe' ->
Reason = xml:get_path_s( Reason = exmpp_presence:get_status(Packet),
Packet, % XXX OLD FORMAT: From.
[{elem, "status"}, cdata]),
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, subscribe, Reason]), [User, Server, FromOld, subscribe, Reason]),
true}; true};
"subscribed" -> 'subscribed' ->
% XXX OLD FORMAT: From.
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, subscribed, ""]), [User, Server, FromOld, subscribed, ""]),
true}; true};
"unsubscribe" -> 'unsubscribe' ->
% XXX OLD FORMAT: From.
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, unsubscribe, ""]), [User, Server, FromOld, unsubscribe, ""]),
true}; true};
"unsubscribed" -> 'unsubscribed' ->
% XXX OLD FORMAT: From.
{ejabberd_hooks:run_fold( {ejabberd_hooks:run_fold(
roster_in_subscription, roster_in_subscription,
LServer, LServer,
false, false,
[User, Server, From, unsubscribed, ""]), [User, Server, FromOld, unsubscribed, ""]),
true}; true};
_ -> _ ->
{true, false} {true, false}
@ -421,21 +454,21 @@ do_route(From, To, Packet) ->
fun({_, R}) -> fun({_, R}) ->
do_route( do_route(
From, From,
jlib:jid_replace_resource(To, R), exmpp_jid:bare_jid_to_jid(To, R),
Packet) Packet)
end, PResources); end, PResources);
true -> true ->
ok ok
end; end;
"message" -> _ when ?IS_MESSAGE(Packet) ->
route_message(From, To, Packet); route_message(From, To, Packet);
"iq" -> _ when ?IS_IQ(Packet) ->
process_iq(From, To, Packet); process_iq(From, To, Packet);
"broadcast" -> #xmlel{name = 'broadcast'} ->
lists:foreach( lists:foreach(
fun(R) -> fun(R) ->
do_route(From, do_route(From,
jlib:jid_replace_resource(To, R), exmpp_jid:bare_jid_to_jid(To, R),
Packet) Packet)
end, get_user_resources(User, Server)); end, get_user_resources(User, Server));
_ -> _ ->
@ -445,17 +478,17 @@ do_route(From, To, Packet) ->
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
case mnesia:dirty_index_read(session, USR, #session.usr) of case mnesia:dirty_index_read(session, USR, #session.usr) of
[] -> [] ->
case Name of case Packet of
"message" -> _ when ?IS_MESSAGE(Packet) ->
route_message(From, To, Packet); route_message(From, To, Packet);
"iq" -> _ when ?IS_IQ(Packet) ->
case xml:get_attr_s("type", Attrs) of case exmpp_iq:get_type(Packet) of
"error" -> ok; 'error' -> ok;
"result" -> ok; 'result' -> ok;
_ -> _ ->
Err = Err =
jlib:make_error_reply( exmpp_iq:error(Packet,
Packet, ?ERR_RECIPIENT_UNAVAILABLE), 'service-unavailable'),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end; end;
_ -> _ ->
@ -465,21 +498,29 @@ do_route(From, To, Packet) ->
Session = lists:max(Ss), Session = lists:max(Ss),
Pid = element(2, Session#session.sid), Pid = element(2, Session#session.sid),
?DEBUG("sending to process ~p~n", [Pid]), ?DEBUG("sending to process ~p~n", [Pid]),
Pid ! {route, From, To, Packet} % XXX OLD FORMAT: From, To, Packet.
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
[?DEFAULT_NS], ?PREFIXED_NS),
Pid ! {route, FromOld, ToOld, PacketOld}
end end
end. end.
route_message(From, To, Packet) -> route_message(From, To, Packet) ->
LUser = To#jid.luser, LUser = To#jid.lnode,
LServer = To#jid.lserver, LServer = To#jid.ldomain,
PrioRes = get_user_present_resources(LUser, LServer), PrioRes = get_user_present_resources(LUser, LServer),
% XXX OLD FORMAT: From, To, Packet.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
[?DEFAULT_NS], ?PREFIXED_NS),
case catch lists:max(PrioRes) of case catch lists:max(PrioRes) of
{Priority, _R} when is_integer(Priority), Priority >= 0 -> {Priority, _R} when is_integer(Priority), Priority >= 0 ->
lists:foreach( lists:foreach(
%% Route messages to all priority that equals the max, if %% Route messages to all priority that equals the max, if
%% positive %% positive
fun({P, R}) when P == Priority -> fun({P, R}) when P == Priority ->
LResource = jlib:resourceprep(R), LResource = exmpp_stringprep:resourceprep(R),
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
case mnesia:dirty_index_read(session, USR, #session.usr) of case mnesia:dirty_index_read(session, USR, #session.usr) of
[] -> [] ->
@ -488,7 +529,8 @@ route_message(From, To, Packet) ->
Session = lists:max(Ss), Session = lists:max(Ss),
Pid = element(2, Session#session.sid), Pid = element(2, Session#session.sid),
?DEBUG("sending to process ~p~n", [Pid]), ?DEBUG("sending to process ~p~n", [Pid]),
Pid ! {route, From, To, Packet} % XXX OLD FORMAT: From, To, Packet.
Pid ! {route, FromOld, ToOld, PacketOld}
end; end;
%% Ignore other priority: %% Ignore other priority:
({_Prio, _Res}) -> ({_Prio, _Res}) ->
@ -496,22 +538,23 @@ route_message(From, To, Packet) ->
end, end,
PrioRes); PrioRes);
_ -> _ ->
case xml:get_tag_attr_s("type", Packet) of case exmpp_message:get_type(Packet) of
"error" -> 'error' ->
ok; ok;
"groupchat" -> 'groupchat' ->
bounce_offline_message(From, To, Packet); bounce_offline_message(From, To, Packet);
"headline" -> 'headline' ->
bounce_offline_message(From, To, Packet); bounce_offline_message(From, To, Packet);
_ -> _ ->
case ejabberd_auth:is_user_exists(LUser, LServer) of case ejabberd_auth:is_user_exists(LUser, LServer) of
true -> true ->
% XXX OLD FORMAT: From, To, Packet.
ejabberd_hooks:run(offline_message_hook, ejabberd_hooks:run(offline_message_hook,
LServer, LServer,
[From, To, Packet]); [FromOld, ToOld, PacketOld]);
_ -> _ ->
Err = jlib:make_error_reply( Err = exmpp_stanza:reply_with_error(
Packet, ?ERR_SERVICE_UNAVAILABLE), Packet, 'service-unaivailable'),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end end
end end
@ -557,9 +600,9 @@ get_user_present_resources(LUser, LServer) ->
%% On new session, check if some existing connections need to be replace %% On new session, check if some existing connections need to be replace
check_for_sessions_to_replace(User, Server, Resource) -> check_for_sessions_to_replace(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = exmpp_stringprep:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = exmpp_stringprep:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = exmpp_stringprep:resourceprep(Resource),
%% TODO: Depending on how this is executed, there could be an unneeded %% TODO: Depending on how this is executed, there could be an unneeded
%% replacement for max_sessions. We need to check this at some point. %% replacement for max_sessions. We need to check this at some point.
@ -606,7 +649,7 @@ check_max_sessions(LUser, LServer) ->
%% Defaults to infinity %% Defaults to infinity
get_max_user_sessions(LUser, Host) -> get_max_user_sessions(LUser, Host) ->
case acl:match_rule( case acl:match_rule(
Host, max_user_sessions, jlib:make_jid(LUser, Host, "")) of Host, max_user_sessions, exmpp_jid:make_bare_jid(LUser, Host)) of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
infinity -> infinity; infinity -> infinity;
_ -> ?MAX_USER_SESSIONS _ -> ?MAX_USER_SESSIONS
@ -616,32 +659,41 @@ get_max_user_sessions(LUser, Host) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process_iq(From, To, Packet) -> process_iq(From, To, Packet) ->
IQ = jlib:iq_query_info(Packet), % XXX OLD FORMAT: From, To, Packet.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
[?DEFAULT_NS], ?PREFIXED_NS),
IQ = jlib:iq_query_info(PacketOld),
case IQ of case IQ of
#iq{xmlns = XMLNS} -> #iq{xmlns = XMLNS} ->
Host = To#jid.lserver, Host = To#jid.ldomain,
case ets:lookup(sm_iqtable, {XMLNS, Host}) of case ets:lookup(sm_iqtable, {XMLNS, Host}) of
[{_, Module, Function}] -> [{_, Module, Function}] ->
ResIQ = Module:Function(From, To, IQ), % XXX OLD FORMAT: From, To, IQ.
ResIQ = Module:Function(FromOld, ToOld, IQ),
if if
ResIQ /= ignore -> ResIQ /= ignore ->
ejabberd_router:route(To, From, % XXX OLD FORMAT: ResIQ.
jlib:iq_to_xml(ResIQ)); ReplyOld = jlib:iq_to_xml(ResIQ),
Reply = exmpp_xml:xmlelement_to_xmlel(ReplyOld,
[?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_router:route(To, From, Reply);
true -> true ->
ok ok
end; end;
[{_, Module, Function, Opts}] -> [{_, Module, Function, Opts}] ->
% XXX OLD FORMAT: From, To, IQ.
gen_iq_handler:handle(Host, Module, Function, Opts, gen_iq_handler:handle(Host, Module, Function, Opts,
From, To, IQ); FromOld, ToOld, IQ);
[] -> [] ->
Err = jlib:make_error_reply( Err = exmpp_iq:error(Packet, 'service-unavailable'),
Packet, ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end; end;
reply -> reply ->
ok; ok;
_ -> _ ->
Err = jlib:make_error_reply(Packet, ?ERR_BAD_REQUEST), Err = exmpp_iq:error(Packet, 'bad-request'),
ejabberd_router:route(To, From, Err), ejabberd_router:route(To, From, Err),
ok ok
end. end.