From, To, Packet);
[] ->
Txt = <<"No module is handling this query">>,
- Err = xmpp:make_error(
- Packet,
- xmpp:err_service_unavailable(Txt, Lang)),
- ejabberd_router:route(To, From, Err)
+ Err = xmpp:err_service_unavailable(Txt, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err)
end;
process_iq(From, To, #iq{type = T} = Packet) when T == get; T == set ->
- Err = xmpp:make_error(Packet, xmpp:err_bad_request()),
- ejabberd_router:route(To, From, Err);
+ Err = xmpp:err_bad_request(),
+ ejabberd_router:route_error(To, From, Packet, Err);
process_iq(From, To, #iq{type = T} = Packet) when T == result; T == error ->
process_iq_reply(From, To, Packet).
bounce_resource_packet(From, To, Packet) ->
Lang = xmpp:get_lang(Packet),
Txt = <<"No available resource found">>,
- Err = xmpp:make_error(Packet,
- xmpp:err_item_not_found(Txt, Lang)),
- ejabberd_router:route(To, From, Err),
+ Err = xmpp:err_item_not_found(Txt, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err),
stop.
%%====================================================================
bounce_offline_message(From, To, Packet) ->
Lang = xmpp:get_lang(Packet),
Txt = <<"User session not found">>,
- Err = xmpp:make_error(
- Packet, xmpp:err_service_unavailable(Txt, Lang)),
- ejabberd_router:route(To, From, Err),
+ Err = xmpp:err_service_unavailable(Txt, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err),
stop.
-spec disconnect_removed_user(binary(), binary()) -> ok.
ejabberd_hooks:run(offline_message_hook, LServer,
[From, To, Packet]);
false ->
- Err = xmpp:make_error(Packet,
- xmpp:err_service_unavailable()),
- ejabberd_router:route(To, From, Err)
+ Err = xmpp:err_service_unavailable(),
+ ejabberd_router:route_error(To, From, Packet, Err)
end
end.
From, To, Packet);
[] ->
Txt = <<"No module is handling this query">>,
- Err = xmpp:make_error(
- Packet,
- xmpp:err_service_unavailable(Txt, Lang)),
- ejabberd_router:route(To, From, Err)
+ Err = xmpp:err_service_unavailable(Txt, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err)
end;
process_iq(From, To, #iq{type = T} = Packet) when T == get; T == set ->
- Err = xmpp:make_error(Packet, xmpp:err_bad_request()),
- ejabberd_router:route(To, From, Err),
+ Err = xmpp:err_bad_request(),
+ ejabberd_router:route_error(To, From, Packet, Err),
ok;
process_iq(_From, _To, #iq{}) ->
ok.
[xmpp:pp(IQ), {E, {R, erlang:get_stacktrace()}}]),
Txt = <<"Module failed to handle the query">>,
Err = xmpp:err_internal_server_error(Txt, IQ#iq.lang),
- ejabberd_router:route(To, From, xmpp:make_error(IQ, Err))
+ ejabberd_router:route_error(To, From, IQ, Err)
end.
-spec process_iq(module(), atom(), iq()) -> ignore | iq().
Access = get_access(Host),
case acl:match_rule(Host, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
Local = jid:make(To#jid.server),
lists:foreach(
Access = get_access(global),
case acl:match_rule(global, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
Local = jid:make(To#jid.server),
lists:foreach(
Access = get_access(Host),
case acl:match_rule(Host, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
announce_online1(ejabberd_sm:get_vh_session_list(Host),
To#jid.server,
Access = get_access(global),
case acl:match_rule(global, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
announce_online1(ejabberd_sm:dirty_get_sessions_list(),
To#jid.server,
Access = get_access(Host),
case acl:match_rule(Host, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
announce_motd(Host, Packet)
end.
Access = get_access(global),
case acl:match_rule(global, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
Hosts = ?MYHOSTS,
[announce_motd(Host, Packet) || Host <- Hosts]
Access = get_access(Host),
case acl:match_rule(Host, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
announce_motd_update(Host, Packet)
end.
Access = get_access(global),
case acl:match_rule(global, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
Hosts = ?MYHOSTS,
[announce_motd_update(Host, Packet) || Host <- Hosts]
Access = get_access(Host),
case acl:match_rule(Host, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
announce_motd_delete(Host)
end.
Access = get_access(global),
case acl:match_rule(global, Access, From) of
deny ->
- Lang = xmpp:get_lang(Packet),
- Txt = <<"Denied by ACL">>,
- Err = xmpp:make_error(Packet, xmpp:err_forbidden(Txt, Lang)),
- ejabberd_router:route(To, From, Err);
+ route_forbidden_error(From, To, Packet);
allow ->
Hosts = ?MYHOSTS,
[announce_motd_delete(Host) || Host <- Hosts]
add_store_hint(El) ->
xmpp:set_subtag(El, #hint{type = store}).
+-spec route_forbidden_error(jid(), jid(), stanza()) -> ok.
+route_forbidden_error(From, To, Packet) ->
+ Lang = xmpp:get_lang(Packet),
+ Err = xmpp:err_forbidden(<<"Denied by ACL">>, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err).
+
%%-------------------------------------------------------------------------
export(LServer) ->
Mod = gen_mod:db_mod(LServer, ?MODULE),
deny ->
ErrText = <<"Only service administrators are allowed "
"to send service messages">>,
- Err = xmpp:make_error(
- Packet, xmpp:err_forbidden(ErrText, Lang)),
- ejabberd_router:route(To, From, Err)
+ Err = xmpp:err_forbidden(ErrText, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err)
end
end;
do_route1(_Host, _ServerHost, _Access, _HistorySize, _RoomShaper,
false ->
Lang = xmpp:get_lang(Packet),
ErrText = <<"Room creation is denied by service policy">>,
- Err = xmpp:make_error(
- Packet, xmpp:err_forbidden(ErrText, Lang)),
- ejabberd_router:route(To, From, Err)
+ Err = xmpp:err_forbidden(ErrText, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err)
end;
false ->
Lang = xmpp:get_lang(Packet),
shaper:update(Activity#activity.message_shaper, Size),
if Activity#activity.message /= undefined ->
ErrText = <<"Traffic rate limit is exceeded">>,
- Err = xmpp:make_error(
- Packet,
- xmpp:err_resource_constraint(ErrText, Lang)),
- ejabberd_router:route(StateData#state.jid, From, Err),
+ Err = xmpp:err_resource_constraint(ErrText, Lang),
+ ejabberd_router:route_error(StateData#state.jid, From, Packet, Err),
{next_state, normal_state, StateData};
Now >= Activity#activity.message_time + MinMessageInterval,
MessageShaperInterval == 0 ->
end
catch _:{xmpp_codec, Why} ->
ErrTxt = xmpp:format_error(Why),
- Err = xmpp:make_error(IQ0, xmpp:err_bad_request(ErrTxt, Lang)),
- ejabberd_router:route(StateData#state.jid, From, Err)
+ Err = xmpp:err_bad_request(ErrTxt, Lang),
+ ejabberd_router:route_error(StateData#state.jid, From, IQ0, Err)
end;
normal_state({route, From, <<"">>, #iq{} = IQ}, StateData) ->
Err = xmpp:err_bad_request(),
{false, _, _, _} when NUsers >= MaxUsers orelse NUsers >= MaxAdminUsers ->
Txt = <<"Too many users in this conference">>,
Err = xmpp:err_resource_constraint(Txt, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
{false, _, _, _} when NConferences >= MaxConferences ->
Txt = <<"You have joined too many conferences">>,
Err = xmpp:err_resource_constraint(Txt, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
end;
{false, _, _, _} ->
Err = xmpp:err_service_unavailable(),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
ErrText = <<"Membership is required to enter this room">>,
xmpp:err_registration_required(ErrText, Lang)
end,
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
{_, true, _, _} ->
ErrText = <<"That nickname is already in use by another occupant">>,
Err = xmpp:err_conflict(ErrText, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
{_, _, false, _} ->
ErrText = <<"That nickname is registered by another person">>,
Err = xmpp:err_conflict(ErrText, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
nopass ->
ErrText = <<"A password is required to enter this room">>,
Err = xmpp:err_not_authorized(ErrText, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
{error, limit} ->
ErrText = <<"Too many CAPTCHA requests">>,
Err = xmpp:err_resource_constraint(ErrText, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(
+ UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
_ ->
ErrText = <<"Unable to generate a CAPTCHA">>,
Err = xmpp:err_internal_server_error(ErrText, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(
+ UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
_ ->
ErrText = <<"Incorrect password">>,
Err = xmpp:err_not_authorized(ErrText, Lang),
- ErrPacket = xmpp:make_error(Packet, Err),
if not IsSubscribeRequest ->
- ejabberd_router:route(UserRoomJID, From, ErrPacket),
+ ejabberd_router:route_error(
+ UserRoomJID, From, Packet, Err),
StateData;
true ->
{error, Err}
ErrText = <<"Your contact offline message queue is "
"full. The message has been discarded.">>,
Lang = xmpp:get_lang(Packet),
- Err = xmpp:make_error(
- Packet, xmpp:err_resource_constraint(ErrText, Lang)),
- ejabberd_router:route(To, From, Err)
+ Err = xmpp:err_resource_constraint(ErrText, Lang),
+ ejabberd_router:route_error(To, From, Packet, Err)
end, Msgs).
webadmin_page(_, Host,