diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-06-03 21:52:11 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-06-03 21:52:11 +0200 |
commit | 8305cc293b34680add10d3770f9d2ef2f12234f8 (patch) | |
tree | eedfb6975230e74660944d20de54cac2bb84c41f /src/mod_client_state.erl | |
parent | Unwrap carbon copies when checking for chat states (diff) |
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).
Diffstat (limited to 'src/mod_client_state.erl')
-rw-r--r-- | src/mod_client_state.erl | 17 |
1 files 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; |