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

Return error when blocking message to offline user

As per XEP-0016 and XEP-0191, return a service-unavailable error when an
incoming message sent to an offline user was blocked by a privacy list.
The same is done for a message sent to an online user, so this avoids a
presence leak.
This commit is contained in:
Holger Weiss 2016-04-24 22:00:15 +02:00
parent b79f09d0eb
commit cebdfb6523

View File

@ -601,15 +601,12 @@ route_message(From, To, Packet, Type) ->
case Type of case Type of
headline -> ok; headline -> ok;
_ -> _ ->
case ejabberd_auth:is_user_exists(LUser, LServer) of case ejabberd_auth:is_user_exists(LUser, LServer) andalso
is_privacy_allow(From, To, Packet) of
true -> true ->
case is_privacy_allow(From, To, Packet) of ejabberd_hooks:run(offline_message_hook, LServer,
true -> [From, To, Packet]);
ejabberd_hooks:run(offline_message_hook, LServer, false ->
[From, To, Packet]);
false -> ok
end;
_ ->
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERR_SERVICE_UNAVAILABLE), ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)