From bc008d40419a94c20498371fac771638a39b84d2 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 25 Mar 2015 00:13:05 +0100 Subject: [PATCH] Update routing for unavailable resources As per RFC 6121, don't reroute non-chat messages sent to unavailable resources. --- src/ejabberd_sm.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index abe15d9ff..ebcf6fa58 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -525,7 +525,15 @@ do_route(From, To, #xmlel{} = Packet) -> case Mod:get_sessions(LUser, LServer, LResource) of [] -> case Name of - <<"message">> -> route_message(From, To, Packet); + <<"message">> -> + case xml:get_attr_s(<<"type">>, Attrs) of + <<"chat">> -> route_message(From, To, Packet); + <<"error">> -> ok; + _ -> + Err = jlib:make_error_reply(Packet, + ?ERR_SERVICE_UNAVAILABLE), + ejabberd_router:route(To, From, Err) + end; <<"iq">> -> case xml:get_attr_s(<<"type">>, Attrs) of <<"error">> -> ok;