From 8f72c27b88cd83e50879caf80d8d2546fd19ef2d Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 17 May 2016 22:12:04 +0200 Subject: mod_client_state: Add "queue_pep" option If the new "queue_pep" option is enabled and the client is inactive, PEP notifications are throttled in a similar way to presence stanzas and chat states. Only the most recent notification of a given node and payload type will be queued from a given contact. --- test/ejabberd_SUITE.erl | 51 +++++++++++++++++++++++++++++++++++ test/ejabberd_SUITE_data/ejabberd.yml | 2 ++ 2 files changed, 53 insertions(+) (limited to 'test') diff --git a/test/ejabberd_SUITE.erl b/test/ejabberd_SUITE.erl index f3f7ebde3..800d5ebf3 100644 --- a/test/ejabberd_SUITE.erl +++ b/test/ejabberd_SUITE.erl @@ -2255,12 +2255,41 @@ client_state_master(Config) -> ChatState = #message{to = Peer, thread = <<"1">>, sub_els = [#chatstate{type = active}]}, Message = ChatState#message{body = [#text{data = <<"body">>}]}, + PepPayload = xmpp_codec:encode(#presence{}), + PepOne = #message{ + to = Peer, + sub_els = + [#pubsub_event{ + items = + [#pubsub_event_items{ + node = <<"foo-1">>, + items = + [#pubsub_event_item{ + id = <<"pep-1">>, + xml_els = [PepPayload]}]}]}]}, + PepTwo = #message{ + to = Peer, + sub_els = + [#pubsub_event{ + items = + [#pubsub_event_items{ + node = <<"foo-2">>, + items = + [#pubsub_event_item{ + id = <<"pep-2">>, + xml_els = [PepPayload]}]}]}]}, %% Wait for the slave to become inactive. wait_for_slave(Config), %% Should be queued (but see below): send(Config, Presence), %% Should replace the previous presence in the queue: send(Config, Presence#presence{type = unavailable}), + %% The following two PEP stanzas should be queued (but see below): + send(Config, PepOne), + send(Config, PepTwo), + %% The following two PEP stanzas should replace the previous two: + send(Config, PepOne), + send(Config, PepTwo), %% Should be queued (but see below): send(Config, ChatState), %% Should replace the previous chat state in the queue: @@ -2279,6 +2308,28 @@ client_state_slave(Config) -> wait_for_master(Config), ?recv1(#presence{from = Peer, type = unavailable, sub_els = [#delay{}]}), + #message{ + from = Peer, + sub_els = + [#pubsub_event{ + items = + [#pubsub_event_items{ + node = <<"foo-1">>, + items = + [#pubsub_event_item{ + id = <<"pep-1">>}]}]}, + #delay{}]} = recv(), + #message{ + from = Peer, + sub_els = + [#pubsub_event{ + items = + [#pubsub_event_items{ + node = <<"foo-2">>, + items = + [#pubsub_event_item{ + id = <<"pep-2">>}]}]}, + #delay{}]} = recv(), ?recv1(#message{from = Peer, thread = <<"1">>, sub_els = [#chatstate{type = composing}, #delay{}]}), diff --git a/test/ejabberd_SUITE_data/ejabberd.yml b/test/ejabberd_SUITE_data/ejabberd.yml index 30fff88fc..1adbcce8a 100644 --- a/test/ejabberd_SUITE_data/ejabberd.yml +++ b/test/ejabberd_SUITE_data/ejabberd.yml @@ -215,6 +215,7 @@ Welcome to this XMPP server." mod_client_state: queue_presence: true queue_chat_states: true + queue_pep: true mod_adhoc: [] mod_configure: [] mod_disco: [] @@ -271,6 +272,7 @@ Welcome to this XMPP server." mod_client_state: queue_presence: true queue_chat_states: true + queue_pep: true mod_adhoc: [] mod_configure: [] mod_disco: [] -- cgit v1.2.3