25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

mod_push: Avoid notification duplicates

Don't let mod_mam and mod_offline both trigger push notifications for
the same message.

Closes #2078.
This commit is contained in:
Holger Weiss 2017-11-06 00:26:20 +01:00
parent 7d8ad17fa1
commit 41c393466c

View File

@ -195,7 +195,7 @@ register_hooks(Host) ->
ejabberd_hooks:add(store_mam_message, Host, ?MODULE,
mam_message, 50),
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
offline_message, 50),
offline_message, 30),
ejabberd_hooks:add(remove_user, Host, ?MODULE,
remove_user, 50).
@ -214,7 +214,7 @@ unregister_hooks(Host) ->
ejabberd_hooks:delete(store_mam_message, Host, ?MODULE,
mam_message, 50),
ejabberd_hooks:delete(offline_message_hook, Host, ?MODULE,
offline_message, 50),
offline_message, 30),
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
remove_user, 50).
@ -354,13 +354,11 @@ mam_message(#message{} = Pkt, LUser, LServer, _Peer, chat, _Dir) ->
_ ->
ok
end,
xmpp:put_meta(Pkt, push_notified, true);
Pkt;
mam_message(Pkt, _LUser, _LServer, _Peer, _Type, _Dir) ->
Pkt.
-spec offline_message({any(), message()}) -> {any(), message()}.
offline_message({_Action, #message{meta = #{push_notified := true}}} = Acc) ->
Acc;
offline_message({Action, #message{to = #jid{luser = LUser,
lserver = LServer}} = Pkt}) ->
case lookup_sessions(LUser, LServer) of