mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Omit push notifications if offline storage failed
This commit removes the 'store_offline_message' hook which didn't allow mod_push to suppress notifications when storing an offline message failed (due to the offline spool size limit being exceeded or due to database issues). Fixes #3120.
This commit is contained in:
parent
19e47375df
commit
0e96d64e60
@ -493,26 +493,20 @@ store_packet({_Action, #message{from = From, to = To} = Packet} = Acc) ->
|
|||||||
case check_event(Packet) of
|
case check_event(Packet) of
|
||||||
true ->
|
true ->
|
||||||
#jid{luser = LUser, lserver = LServer} = To,
|
#jid{luser = LUser, lserver = LServer} = To,
|
||||||
case ejabberd_hooks:run_fold(store_offline_message, LServer,
|
|
||||||
Packet, []) of
|
|
||||||
drop ->
|
|
||||||
Acc;
|
|
||||||
NewPacket ->
|
|
||||||
TimeStamp = erlang:timestamp(),
|
TimeStamp = erlang:timestamp(),
|
||||||
Expire = find_x_expire(TimeStamp, NewPacket),
|
Expire = find_x_expire(TimeStamp, Packet),
|
||||||
OffMsg = #offline_msg{us = {LUser, LServer},
|
OffMsg = #offline_msg{us = {LUser, LServer},
|
||||||
timestamp = TimeStamp,
|
timestamp = TimeStamp,
|
||||||
expire = Expire,
|
expire = Expire,
|
||||||
from = From,
|
from = From,
|
||||||
to = To,
|
to = To,
|
||||||
packet = NewPacket},
|
packet = Packet},
|
||||||
case store_offline_msg(OffMsg) of
|
case store_offline_msg(OffMsg) of
|
||||||
ok ->
|
ok ->
|
||||||
{offlined, NewPacket};
|
{offlined, Packet};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
discard_warn_sender(Packet, Reason),
|
discard_warn_sender(Packet, Reason),
|
||||||
stop
|
stop
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
maybe_update_cache(To, Packet),
|
maybe_update_cache(To, Packet),
|
||||||
|
@ -209,8 +209,8 @@ register_hooks(Host) ->
|
|||||||
c2s_stanza, 50),
|
c2s_stanza, 50),
|
||||||
ejabberd_hooks:add(store_mam_message, Host, ?MODULE,
|
ejabberd_hooks:add(store_mam_message, Host, ?MODULE,
|
||||||
mam_message, 50),
|
mam_message, 50),
|
||||||
ejabberd_hooks:add(store_offline_message, Host, ?MODULE,
|
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
|
||||||
offline_message, 50),
|
offline_message, 55),
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
||||||
remove_user, 50).
|
remove_user, 50).
|
||||||
|
|
||||||
@ -228,8 +228,8 @@ unregister_hooks(Host) ->
|
|||||||
c2s_stanza, 50),
|
c2s_stanza, 50),
|
||||||
ejabberd_hooks:delete(store_mam_message, Host, ?MODULE,
|
ejabberd_hooks:delete(store_mam_message, Host, ?MODULE,
|
||||||
mam_message, 50),
|
mam_message, 50),
|
||||||
ejabberd_hooks:delete(store_offline_message, Host, ?MODULE,
|
ejabberd_hooks:delete(offline_message_hook, Host, ?MODULE,
|
||||||
offline_message, 50),
|
offline_message, 55),
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
||||||
remove_user, 50).
|
remove_user, 50).
|
||||||
|
|
||||||
@ -373,10 +373,12 @@ mam_message(#message{} = Pkt, LUser, LServer, _Peer, _Nick, chat, Dir) ->
|
|||||||
mam_message(Pkt, _LUser, _LServer, _Peer, _Nick, _Type, _Dir) ->
|
mam_message(Pkt, _LUser, _LServer, _Peer, _Nick, _Type, _Dir) ->
|
||||||
Pkt.
|
Pkt.
|
||||||
|
|
||||||
-spec offline_message(message()) -> message().
|
-spec offline_message({any(), message()}) -> {any(), message()}.
|
||||||
offline_message(#message{meta = #{mam_archived := true}} = Pkt) ->
|
offline_message({offlined, #message{meta = #{mam_archived := true}}} = Acc) ->
|
||||||
Pkt; % Push notification was triggered via MAM.
|
Acc; % Push notification was triggered via MAM.
|
||||||
offline_message(#message{to = #jid{luser = LUser, lserver = LServer}} = Pkt) ->
|
offline_message({offlined,
|
||||||
|
#message{to = #jid{luser = LUser,
|
||||||
|
lserver = LServer}} = Pkt} = Acc) ->
|
||||||
case lookup_sessions(LUser, LServer) of
|
case lookup_sessions(LUser, LServer) of
|
||||||
{ok, [_|_] = Clients} ->
|
{ok, [_|_] = Clients} ->
|
||||||
?DEBUG("Notifying ~ts@~ts of offline message", [LUser, LServer]),
|
?DEBUG("Notifying ~ts@~ts of offline message", [LUser, LServer]),
|
||||||
@ -384,7 +386,9 @@ offline_message(#message{to = #jid{luser = LUser, lserver = LServer}} = Pkt) ->
|
|||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
Pkt.
|
Acc;
|
||||||
|
offline_message(Acc) ->
|
||||||
|
Acc.
|
||||||
|
|
||||||
-spec c2s_session_pending(c2s_state()) -> c2s_state().
|
-spec c2s_session_pending(c2s_state()) -> c2s_state().
|
||||||
c2s_session_pending(#{push_enabled := true, mgmt_queue := Queue} = State) ->
|
c2s_session_pending(#{push_enabled := true, mgmt_queue := Queue} = State) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user