From 8305cc293b34680add10d3770f9d2ef2f12234f8 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 3 Jun 2016 21:52:11 +0200 Subject: [PATCH] XEP-0352: Pass chat states of other resources Don't hold back (carbon copies of) chat states from other resources, as they might be used to sync the state of conversations across clients. E.g., if one client becomes active, another one might want to remove a notification (immediately). --- src/mod_client_state.erl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mod_client_state.erl b/src/mod_client_state.erl index 6b79aec0d..0a144195f 100644 --- a/src/mod_client_state.erl +++ b/src/mod_client_state.erl @@ -165,10 +165,21 @@ filter_presence(Acc, _Host, _Stanza) -> Acc. filter_chat_states({C2SState, _OutStanzas} = Acc, Host, #xmlel{name = <<"message">>} = Stanza) -> - case jlib:is_standalone_chat_state(jlib:unwrap_carbon(Stanza)) of + Payload = jlib:unwrap_carbon(Stanza), + case jlib:is_standalone_chat_state(Payload) of true -> - ?DEBUG("Got standalone chat state notification", []), - queue_add(chatstate, Stanza, Host, C2SState); + From = fxml:get_tag_attr_s(<<"from">>, Payload), + To = fxml:get_tag_attr_s(<<"to">>, Payload), + case {jid:from_string(From), jid:from_string(To)} of + {#jid{luser = U, lserver = S}, #jid{luser = U, lserver = S}} -> + %% Don't queue (carbon copies of) chat states from other + %% resources, as they might be used to sync the state of + %% conversations across clients. + Acc; + _ -> + ?DEBUG("Got standalone chat state notification", []), + queue_add(chatstate, Stanza, Host, C2SState) + end; false -> Acc end;