Fixes #1480.
process_offline_msg(Msg, State = #state{user = U, server = S}) ->
To = jid:make(U, S),
ejabberd_hooks:run_fold(
- offline_message_hook, To#jid.lserver, pass,
- [xmpp:set_to(Msg, To)]),
+ offline_message_hook, To#jid.lserver, {pass, xmpp:set_to(Msg, To)}, []),
{ok, State}.
-spec process_presence(presence(), state()) -> {ok, state()} | {error, _}.
open_session/6,
close_session/4,
check_in_subscription/6,
- bounce_offline_message/2,
+ bounce_offline_message/1,
disconnect_removed_user/2,
get_user_resources/2,
get_user_present_resources/2,
false -> {stop, false}
end.
--spec bounce_offline_message(bounce | any(), message()) -> stop.
+-spec bounce_offline_message({bounce, message()} | any()) -> any().
-bounce_offline_message(bounce = Acc, Packet) ->
+bounce_offline_message({bounce, Packet} = Acc) ->
Lang = xmpp:get_lang(Packet),
Txt = <<"User session not found">>,
Err = xmpp:err_service_unavailable(Txt, Lang),
ejabberd_router:route_error(Packet, Err),
{stop, Acc};
-bounce_offline_message(Acc, _Packet) ->
+bounce_offline_message(Acc) ->
Acc.
-spec disconnect_removed_user(binary(), binary()) -> ok.
is_privacy_allow(Packet) of
true ->
ejabberd_hooks:run_fold(offline_message_hook,
- LServer, bounce,
- [Packet]);
+ LServer, {bounce, Packet}, []);
false ->
Err = xmpp:err_service_unavailable(),
ejabberd_router:route_error(Packet, Err)
end,
ejabberd_hooks:run_fold(
offline_message_hook,
- LServer, pass, [xmpp:set_from_to(Msg, From, To)]);
+ LServer, {pass, xmpp:set_from_to(Msg, From, To)}, []);
_ ->
ok
catch _:{xmpp_codec, Why} ->
remove_user/2, remove_room/3, mod_opt_type/1, muc_process_iq/2,
muc_filter_message/5, message_is_archived/3, delete_old_messages/2,
get_commands_spec/0, msg_to_el/4, get_room_config/4, set_room_option/3,
- offline_message/2]).
+ offline_message/1]).
-include("xmpp.hrl").
-include("logger.hrl").
ejabberd_hooks:add(user_send_packet, Host, ?MODULE,
user_send_packet_strip_tag, 500),
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
- offline_message, 50),
+ offline_message, 40),
ejabberd_hooks:add(muc_filter_message, Host, ?MODULE,
muc_filter_message, 50),
ejabberd_hooks:add(muc_process_iq, Host, ?MODULE,
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
user_send_packet_strip_tag, 500),
ejabberd_hooks:delete(offline_message_hook, Host, ?MODULE,
- offline_message, 50),
+ offline_message, 40),
ejabberd_hooks:delete(muc_filter_message, Host, ?MODULE,
muc_filter_message, 50),
ejabberd_hooks:delete(muc_process_iq, Host, ?MODULE,
end,
{Pkt2, C2SState}.
--spec offline_message(any(), message()) -> any().
-offline_message(Acc, #message{from = Peer, to = To} = Pkt) ->
+-spec offline_message({any(), message()}) -> {any(), message()}.
+offline_message({Action, #message{from = Peer, to = To} = Pkt} = Acc) ->
LUser = To#jid.luser,
LServer = To#jid.lserver,
case should_archive(Pkt, LServer) of
true ->
Pkt1 = strip_my_archived_tag(Pkt, LServer),
case store_msg(undefined, Pkt1, LUser, LServer, Peer, recv) of
- {ok, _ID} ->
- archived;
+ {ok, ID} ->
+ {archived, set_stanza_id(Pkt1, To, ID)};
_ ->
Acc
end;
-export([start/2, stop/1, send_metrics/4, opt_type/1, mod_opt_type/1,
depends/2, reload/3]).
--export([offline_message_hook/2,
+-export([offline_message_hook/1,
sm_register_connection_hook/3, sm_remove_connection_hook/3,
user_send_packet/1, user_receive_packet/1,
s2s_send_packet/1, s2s_receive_packet/1,
%%====================================================================
%% Hooks handlers
%%====================================================================
--spec offline_message_hook(any(), message()) -> any().
-offline_message_hook(Acc, #message{to = #jid{lserver = LServer}}) ->
+-spec offline_message_hook({any(), message()}) -> {any(), message()}.
+offline_message_hook({_Action, #message{to = #jid{lserver = LServer}}} = Acc) ->
push(LServer, offline_message),
Acc.
-export([start/2,
stop/1,
reload/3,
- store_packet/2,
+ store_packet/1,
store_offline_msg/5,
c2s_self_presence/1,
get_sm_features/5,
false
end.
--spec store_packet(any(), message()) -> any().
-store_packet(Acc, #message{from = From, to = To} = Packet) ->
+-spec store_packet({any(), message()}) -> {any(), message()}.
+store_packet({_Action, #message{from = From, to = To} = Packet} = Acc) ->
case need_to_store(To#jid.lserver, Packet) of
true ->
case check_event(Packet) of
from = From,
to = To,
packet = NewPacket},
- offlined
+ {offlined, NewPacket}
end;
_ -> Acc
end;