aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2017-08-18 16:44:32 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2017-08-18 16:44:32 +0200
commit13ad754eccbcc0305aae903b188c87dbbc77d31e (patch)
treeb01d4dc7bf57992bf5990ba23bc686593a4aa026
parentFix mod_multicast start and reading of configured limits (#1949) (diff)
Suppress push notifications for online clients
When a client enabled push notifications during the current session, notifications should be suppressed as long as the client is online. Suppressing the notification didn't work for the case where the notification was triggered by MAM, but this is now fixed.
-rw-r--r--src/ejabberd_sm.erl3
-rw-r--r--src/mod_push.erl3
-rw-r--r--test/push_tests.erl2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl
index 5771a5bbf..d93e66473 100644
--- a/src/ejabberd_sm.erl
+++ b/src/ejabberd_sm.erl
@@ -317,7 +317,8 @@ get_session_sids(User, Server) ->
LUser = jid:nodeprep(User),
LServer = jid:nameprep(Server),
Mod = get_sm_backend(LServer),
- online(get_sessions(Mod, LUser, LServer)).
+ OnlineSs = online(get_sessions(Mod, LUser, LServer)),
+ [SID || #session{sid = SID} <- OnlineSs].
-spec set_offline_info(sid(), binary(), binary(), binary(), info()) -> ok.
diff --git a/src/mod_push.erl b/src/mod_push.erl
index 55db7c0e9..90f4ba55e 100644
--- a/src/mod_push.erl
+++ b/src/mod_push.erl
@@ -546,8 +546,9 @@ delete_sessions(LUser, LServer, LookupFun, Mod) ->
-> [push_session()].
drop_online_sessions(LUser, LServer, Clients) ->
SessIDs = ejabberd_sm:get_session_sids(LUser, LServer),
+ ?WARNING_MSG("SessIDs: ~p", [SessIDs]),
[Client || {TS, _, _, _} = Client <- Clients,
- not lists:keyfind(TS, 1, SessIDs)].
+ lists:keyfind(TS, 1, SessIDs) == false].
%%--------------------------------------------------------------------
%% Caching.
diff --git a/test/push_tests.erl b/test/push_tests.erl
index 4b49cc8fe..04840bad5 100644
--- a/test/push_tests.erl
+++ b/test/push_tests.erl
@@ -134,8 +134,6 @@ mam_slave(Config) ->
self_presence(Config, available),
ct:comment("Receiving message from offline storage"),
recv_test_message(Config),
- ct:comment("Re-enabling push notifications"),
- ok = enable_push(Config),
ct:comment("Enabling MAM"),
ok = enable_mam(Config),
ct:comment("Letting the master know that we're ready"),